按钮点击顺序,并获取按钮的id

来源:百度文库 编辑:神马文学网 时间:2024/05/14 10:44:03
定义一个全局变量 indx

int indx = 1;

在button_click事件中
{
((button)sender).text += indx.tostring()
indx++
}
  其实只要handler : function(btn){ alert(btn.id) }即可。
来源:一起Ext
原文地址:http://www.17ext.com/showtopic.aspx?topicid=965&onlyauthor=1
static string allText = "";
static int clickNum = 0;

protected void Button1_Click(object sender, EventArgs e)
        {
            Button1.Enabled = false;
            clickNum = clickNum + 1;
            Button1.Text = Button1 + "-" + clickNum.ToString();
            if (allText == string.Empty)
                allText = Button1.ID;
            else
                allText += "," + Button1.ID;
        }

protected void Button2_Click(object sender, EventArgs e)
        {
            Button2.Enabled = false;
            clickNum = clickNum + 1;
            Button2.Text = Button2.Text + "-" + clickNum.ToString();
            if (allText == string.Empty)
                allText = Button2.ID;
            else
                allText += "," + Button2.ID;
        }