大家好,我的一个模板里的一个服务器按钮,事件无法响应,事件是在.cs里面写的
protected System.Web.UI.WebControls.Button Button1;声名
然后
private void InitializeComponent()
{    
Button1=new  Button();                            
this.Button1.Click += new System.EventHandler(this.Button1_Click); }
然后在写 private void Button1_Click(object sender, System.EventArgs e)
{
this.Response.Redirect ("webform2.aspx");
}
没用啊,点击没有反映啊,帮帮忙啊谢谢了

解决方案 »

  1.   

    aspx中AutoEventWireup="true"
    看看
      

  2.   

    protected System.Web.UI.WebControls.Button Button1;声名
    然后
    private void InitializeComponent()
    {    
    Button1=new  Button();                            
    this.Button1.Click += new System.EventHandler(this.Button1_Click); }
    然后在写 private void Button1_Click(object sender, System.EventArgs e)
    {
    this.Response.Redirect ("webform2.aspx");
    }
    就是这么写的啊
      

  3.   

    Button1是模板控件里的一个服务器控件ID
      

  4.   

    模板内的按钮?是什么模板?
    你可以直接在HTML页面中写上该按钮的事件,后台写上相应的事件代码即可调用,不需要使用后台代码委托.
      

  5.   

    怎么写啊,能详细点吗?谢谢啊
    我的那个模板是DATAGRID里的一个TemplateColumn。你能说的详细吗?急急啊
      

  6.   

    如果是datagrid里面的模板,你应该首先设置该按钮的commandname,那么就可以再datagrid的itemdatabound事件里面处理该按钮的单击事件!
      

  7.   

    模版里没办法这样响应的,只有通过CommandName或CommandAgument来获取
      

  8.   

    private void dtgposition_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    if(e.CommandName=="Button1")
    {}
    }