Kum*_*mar 6 c# asp.net user-controls event-handling
我有一个用户控件,其中包含一个名为upload的按钮.按钮单击事件如下所示:
protected void btnUpload_Click(object sender, EventArgs e)
{
// Upload the files to the server
}
Run Code Online (Sandbox Code Playgroud)
在存在用户控件的页面上,在用户点击上传按钮后,我想在用户控件中执行按钮点击事件代码后立即执行某些操作.如何在完成工作后点击Click事件?
您必须在用户控件中创建一个事件,例如:
public event EventHandler ButtonClicked;
Run Code Online (Sandbox Code Playgroud)
然后在你的方法中激活事件......
protected void btnUpload_Click(object sender, EventArgs e)
{
// Upload the files to the server
if(ButtonClicked!=null)
ButtonClicked(this,e);
}
Run Code Online (Sandbox Code Playgroud)
然后,您将能够附加到用户控件的ButtonClicked事件.
| 归档时间: |
|
| 查看次数: |
3413 次 |
| 最近记录: |