GrayFox
GrayFox

Reputation: 814

Can't overload BulletedList OnClick event (BulletedListEventHandler)

I'm stuck with a

CS0123 no overload matches delegate 'BulletedListEventHandler'

error when page loading, whereas I can't see any problem ... I hope your eyes could help me :p

Here is my front code :

<div class="ListHyperLink"">
    <asp:BulletedList runat="server" ID="Liste_Documents_Utiles" DisplayMode="HyperLink" OnClick="ItemsBulletedList_Click"></asp:BulletedList>
</div>

Then I fill in the control with a databind (block code not relevant here I guess) and here is the code-behind block I'd like to fire while selecting an HyperLink from the bulletedList :

  public void ItemsBulletedList_Click(object sender, BulletedListEventHandler e)
{
    HyperLink lienATelecharge = (HyperLink) e.Target;
    DownloadFile download_file = new DownloadFile(this, lienATelecharge.NavigateUrl.Replace(@"\", "/"));
}

I checked replacing with a simple EventArgs and linking to a asp:button OnClick and the event does fire. So the error doesn't seem to come out from somewhere else...

EDIT thanks to Brian Mains answer :

Here is my new code :

 public void LinkBulletedList_Click(object sender, BulletedListEventArgs e)
{
    int index = e.Index;

    ListItem lienATelecharge = (ListItem)Liste_Documents_Utiles.Items[index];

    DownloadFile download_file = new DownloadFile(this, Liste_Documents_Utiles.Value);
}

And then pass DisplayMode="HyperLink" to DisplayMode="LinkButton".

Upvotes: 0

Views: 81

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

Change this:

public void ItemsBulletedList_Click(object sender, BulletedListEventHandler e)

to:

public void ItemsBulletedList_Click(object sender, BulletedListEventArgs e)

Upvotes: 1

Related Questions