我已经在我的用户控件上声明了一个事件
public event EventHandler<AddressEventArgs> SaveButtonClick;
protected void ButtonSave_Click(object sender, EventArgs e)
{
if (SaveButtonClick != null)
{
SaveButtonClick(this, new AddressEventArgs) ;
}
}
在我将用户控件添加到新页面后,我将如何捕获 用户控件引发的事件?
最佳答案
您可以为事件设置 [Browsable]
属性,也可以强制绑定(bind)到事件。
userControl.SaveButtonClick += new EventHandler(handlerFunctionName);
public void handlerFunctionName(AddressEventArgs args)
{
// Here, you have access to args in response the the event of your user control
}
关于c# - 在用户控件 asp.net 中声明事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6574569/