Asp.net 如何加上「;OnClick";事件,从代码隐藏到按钮?
我把这个按钮(称为“接受”)写在一个动作中Asp.net 如何加上「;OnClick";事件,从代码隐藏到按钮?,asp.net,button,onclick,code-behind,Asp.net,Button,Onclick,Code Behind,我把这个按钮(称为“接受”)写在一个动作中 protected TableRow AddLineToNotificationsPanel(string type,int UserCode) { TableRow NotificationTR = new TableRow(); TableCell AcceptTC = new TableCell(); Button Accept = new Button(); NotificationTR.Ce
protected TableRow AddLineToNotificationsPanel(string type,int UserCode)
{
TableRow NotificationTR = new TableRow();
TableCell AcceptTC = new TableCell();
Button Accept = new Button();
NotificationTR.Cells.Add(AcceptTC);
AcceptTC.Controls.Add(Accept);
Accept.Attributes.Add("OnClick", "check1");
return NotificationTR;
}
这就是动作“check1”(仅用于检查点击是否有效)
单击按钮后,标签1上的文本不会更改
你知道为什么它不起作用吗?
谢谢。您需要将事件附加到此按钮。你可以这样做:
Accept.Click+=neweventhandler(选中1)代码>非常有效!谢谢
protected void check1(object sender, EventArgs e)
{
Label1.Text = "TEXT CHANGED !";
}