我有按钮的id,如何把按钮的text改了
比如我知道按钮的id是button1,但是我写button1.text= "btn "的时候系统总认为button1是string类型
------解决方案--------------------对啊,就是30个按钮都调用同一个点击事件嘛?
private void ButtonAll_Click(object sender, System.EventArgs e)
{
((Button)(sender)).Text = "Hello World ";
}
我这个就可以做到啊?
------解决方案--------------------你既然是三十个按钮,即使是调用同一个事件,那和调用三十个有什么区别,处理起来还不是一样?
前台
<asp:Button ID= "btn_Test01 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test00 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test02 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test03 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test04 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test0n5 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test06 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test07 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test08 " runat=server OnClick= "btn_Test01_Click " /> <br />
<asp:Button ID= "btn_Test09 " runat=server OnClick= "btn_Test01_Click " /> <br />
后台:
protected void btn_Test01_Click(object sender, EventArgs e)
{
((Button)(sender)).Text=Session[ "user "].ToString();
}