sender处理程序的参数包含对引发事件的控件的引用.
private void MyClickEventHandler(object sender, EventArgs e)
{
Button theButton = (Button)sender;
...
}
Run Code Online (Sandbox Code Playgroud)
编辑:等待,在Load事件中?那是一个小问题.我能想到的一件事是:Request的Form集合将包含提交按钮的键/值,但不包含其他键.所以你可以这样做:
protected void Page_Load(object sender, EventArgs e)
{
Button theButton = null;
if (Request.Form.AllKeys.Contains("button1"))
theButton = button1;
else if (Request.Form.AllKeys.Contains("button2"))
theButton = button2;
...
}
Run Code Online (Sandbox Code Playgroud)
不是很优雅,但你明白了......
| 归档时间: |
|
| 查看次数: |
13572 次 |
| 最近记录: |