I would like to close the browser window when an ASP.NET operation has succeeded. The code below is triggered by a button that resides in an Ajax UpdatePanel.
我想关闭浏览器窗口时ASP。净操作成功。下面的代码由驻留在Ajax UpdatePanel中的按钮触发。
Page.ClientScript.RegisterClientScriptBlock(typeof(LeaveApproval), "ShowSuccess", "<script language=javascript>window.opener=self; self.close();</script>");
However, this code does not seem to have any effect. The window is not closed. When I enter the javascript into the URL bar of my browser it works fine, so I'm guessing this has something to do with using the ClientScriptManager together with Ajax.
然而,这段代码似乎没有任何效果。窗户没关。当我将javascript输入到浏览器的URL栏时,它工作得很好,所以我猜想这与使用ClientScriptManager和Ajax有关。
Any idea what I am doing wrong?
知道我做错了什么吗?
1 个解决方案
#1
4
This link by Scott Klueppel helped me solve the problem...
Scott Klueppel的这个链接帮助我解决了这个问题……
Rather use...
而使用……
ScriptManager.RegisterStartupScript
instead of
而不是
Page.ClientScript.RegisterClientScriptBlock.
#1
4
This link by Scott Klueppel helped me solve the problem...
Scott Klueppel的这个链接帮助我解决了这个问题……
Rather use...
而使用……
ScriptManager.RegisterStartupScript
instead of
而不是
Page.ClientScript.RegisterClientScriptBlock.