CommandName 问题
三个按扭,定义了三个CommandName,分别为a,b,c功能代码如下
protected void Button1_Click(object sender, EventArgs e)
{
if (((Button)sender).CommandName == "a")
{
Response.Write("a");
}
if (((Button)sender).CommandName == "b")
{
Response.Write("b");
}
if (((Button)sender).CommandName == "c")
{
Response.Write("c");
}
}
问题:在点CommandName为a时要显示结果,其它两个就没反应,望高手指点
------解决方案--------------------Button1.Click+=new EventHandler(Button1_Click);
Button2.Click+=new EventHandler(Button1_Click);
Button3.Click+=new EventHandler(Button1_Click);