开发者

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 开发者_如何学Cit 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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜