用户控件声明事件

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

你可能感兴趣的:(Microsoft,asp.net,asp,vb,VB.NET)