views:

394

answers:

1

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?

+2  A: 

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

Rather use...

ScriptManager.RegisterStartupScript

instead of

Page.ClientScript.RegisterClientScriptBlock.
willem