动态添加了N个按钮,按钮能够正常添加,可是在给按钮注册事件的时候没效果了,需要的效果是点击按钮跳转。帮忙看下哪里错了,谢谢。   //添加按钮
    private void AddBtn(string txt, string id, string type)
    {
        Button btn = new Button();
        btn.ID = "btn" + tr.Controls.Count.ToString();
        btn.CommandArgument = id;
        btn.Text = txt;
        btn.CssClass = "btncss";
 
        if (type == "1")
            btn.Click += new EventHandler(btn1_Click);                                      //2种方法都不行
        // btn.Attributes.Add("onclick", "javascript:location='http://www.baidu.com';");    //
        else if (type == "2")
            //btn.Click += new EventHandler(btn2_Click);
            btn.Attributes.Add("onclick", "<script>alert('2')</script>");
        else if (type == "3")
            //    btn.Click += new EventHandler(btn3_Click);
            btn.Attributes.Add("onclick", "<script>alert('3')</script>");
        tr.Controls.Add(btn);
    }
  public void btn1_Click(object sender, EventArgs e)
    {
        Response.Redirect("http://www.baidu.com");    
    }