页面中有个按钮名称为btnclose,属性为隐藏,我希望在别的地方调用他的onclick事件来关闭当前页面
在cs文件里加上这一句
btnclose.Attributes.Add("onClick", "win.removewin(win.currentwin)");
这表示给btnclose加个onclick事件,还需要手工去调用这个事件才能执行吗?请问要怎么让他执行btnclose的onclick事件呢?

解决方案 »

  1.   

    在后台调用
    比如你的后台代码为:
     protected void BtnSubmit_Click(object sender, EventArgs e)
     {
        //your code
    }在其他方法调用时
    BtnSubmit_Click(null,null);
      

  2.   

    ClientScript.RegisterStartupScript(this.GetType(), "a", "<script>win.removewin(win.currentwin)</script>"); 
     
     
     
    ----------------------------------签----------名----------栏----------------------------------
      

  3.   

    其实你可以把btnclose事件写在js里,在后台调用
    Page.RegisterClientScriptBlock("btnclose", "<script>btnclose()</script>");
      

  4.   

    不知道你对jquery 熟悉不
    $("#这个button的id").click()
    在你想要执行这个button的点击效果时就调用这个代码。
    其实你想关闭这个页面,没有必要来通过点击这个button来实现啊
    直接用js来处理就可以了
      

  5.   

    看标题,是调用onclick事件,不是调函数,所以:
    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>btnclose.onclick();</script>");
      

  6.   

    btnclose.click();  //并且不是所有浏览器都支持。