Peris by Night
Peris by Night

Reputation: 1

Unable to add a event handler in silverlight

I position a button as "Press to see Eifel"

<button type="button" id="Eifel">Eifel</button><br />

And in the MainPage I try to add an event handler for this button but it fails

HtmlElement htmlEl = htmlDoc.GetElementById("Eifel");
htmlEl.AttachEvent("onclick", new EventHandler<HtmlEventArgs>(onClickEifel));

The editor keeps underlining the above EventHandler red with message that "Sorry no overload matches for Eventhandler.....found".

This is real question, not homework. I am learning the basics and couldn't find an answer except stackoverflow.

Thank you

Upvotes: 0

Views: 489

Answers (1)

Pero P.
Pero P.

Reputation: 26982

Your method onClickEifel (or onClickConvert) has to have a signature that matches the EventHandler<TEventArgs> delegate, so in your case:

private void onClickEifel(object sender, HtmlEventArgs e) 
{ 
   // your code
}

Is that the case? Some reading on Delegates if you require it:

Delegates (C# Programming Guide)
Using Delegates (C# Programming Guide)

Upvotes: 1

Related Questions