silverlight 4.0 - Can you create an event in a user control, if so, how? -


i have created user control containing datepicker , want create event in user control linking datepicker datechanged event. custom user control used in itemscontrol.

yes. add public event control. , add method looks delegates attached event. if there delegates, raise event. here's example:

in user control:

public partial class controls_usercomments : system.web.ui.usercontrol {     // event delegates may listen     public event eventhandler commentediting;      protected void page_load(object sender, eventargs e)     {     // handle event in user control , bubble event delegates         gridview_comments.rowcancelingedit += new gridviewcancelediteventhandler(gridview_comments_rowcancelingedit);     }      void gridview_comments_rowcancelingedit(object sender, gridviewcancelediteventargs e)     {         gridview_comments.editindex = -1;         gridview_comments.databind();          // raise event attached delegates         if (commentediting != null)             commentediting(this, eventargs.empty);     } } 

now, in web form utilizing user control:

<ppc:usercomments id="usercomments_observationcomments" runat="server"     oncommentediting="refreshcomments"     /> 

good luck!


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -