且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

难道当一个局部回传叫ClientScriptmanager工作?

更新时间:2023-12-05 14:48:28

斯科特Klueppel此链接帮我解决了问题...

而使用...

  ScriptManager.RegisterStartupScript
 

而不是

  Page.ClientScript.RegisterClientScriptBlock。
 

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.

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.

Any idea what I am doing wrong?

This link by Scott Klueppel helped me solve the problem...

Rather use...

ScriptManager.RegisterStartupScript

instead of

Page.ClientScript.RegisterClientScriptBlock.