Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何加上「;OnClick";事件,从代码隐藏到按钮?_Asp.net_Button_Onclick_Code Behind - Fatal编程技术网

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 !";
    }