【发布时间】:2015-12-27 01:21:08
【问题描述】:
当按下 DoButton 时,我会打开一个像这样的新窗口:
//mainform.aspx
protected void DoButton_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open('mypage.aspx?action=hello', null, 'height=500,width=900,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
}
protected void IWillClose(){ //more code here...}
mypage.aspx 有 2 个按钮:确认和取消。每当按下这些按钮中的任何一个时,窗口就会关闭。
问题:有什么方法可以在这个新窗口关闭时在mainform.aspx 中调用IWillClose();?
【问题讨论】:
-
是的,在你的项目中新建一个c#类(.cs文件),并定义一些公共的
static方法,例如:public static void IWillClose(),这样你就可以在你的项目的任何地方调用这些方法(在这种情况下,在Confirm和Cancel点击事件中调用它)
标签: asp.net .net gridview webforms user-controls