expose an event from your user control
a.ascx:
public event EventHandler MyEvent;
in your control's event handler, do
if (MyEvent != null)
MyEvent(sender, EventArgs.Empty);
//the syntax for VB.NET is RaiseEvent
..
in your aspx page:
<cc:YourASCX runat="server" OnMyEvent="SomeHandler" ..>
in SomeHandler, you can do anything you want
you might need to consider to use a custom delegate and EventArgs, see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondefiningcustomevent.asp
a.ascx:
public event EventHandler MyEvent;
in your control's event handler, do
if (MyEvent != null)
MyEvent(sender, EventArgs.Empty);
//the syntax for VB.NET is RaiseEvent
..
in your aspx page:
<cc:YourASCX runat="server" OnMyEvent="SomeHandler" ..>
in SomeHandler, you can do anything you want
you might need to consider to use a custom delegate and EventArgs, see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondefiningcustomevent.asp
博客介绍了在用户控件中暴露事件的方法。在a.ascx文件里定义事件,在控件事件处理程序中触发事件,还给出了VB.NET的语法。同时说明了在aspx页面中使用该事件,在事件处理函数里可按需操作,还提供了自定义委托和EventArgs的参考链接。
6418

被折叠的 条评论
为什么被折叠?



