页面中有个按钮名称为btnclose,属性为隐藏,我希望在别的地方调用他的onclick事件来关闭当前页面
在cs文件里加上这一句
btnclose.Attributes.Add("onClick", "win.removewin(win.currentwin)");
这表示给btnclose加个onclick事件,还需要手工去调用这个事件才能执行吗?请问要怎么让他执行btnclose的onclick事件呢?
在cs文件里加上这一句
btnclose.Attributes.Add("onClick", "win.removewin(win.currentwin)");
这表示给btnclose加个onclick事件,还需要手工去调用这个事件才能执行吗?请问要怎么让他执行btnclose的onclick事件呢?
比如你的后台代码为:
protected void BtnSubmit_Click(object sender, EventArgs e)
{
//your code
}在其他方法调用时
BtnSubmit_Click(null,null);
Page.RegisterClientScriptBlock("btnclose", "<script>btnclose()</script>");
$("#这个button的id").click()
在你想要执行这个button的点击效果时就调用这个代码。
其实你想关闭这个页面,没有必要来通过点击这个button来实现啊
直接用js来处理就可以了
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>btnclose.onclick();</script>");