Click here to Skip to main content
15,886,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is script doesn't work when using updatepanel in page
HTML
ClientScript.RegisterStartupScript(Page.GetType(), "closing", "<script>window.close();</script>");
Posted
Updated 10-Oct-11 20:29pm
v2

in updtepanel try with following
C#
string CloseWindow;
        
CloseWindow = "alert('welcome')";
 
ScriptManager.RegisterStartupScript(UpdatePanelID,UpdatePanelID.GetType(), "CloseWindow", CloseWindow, true);
 
Share this answer
 
Comments
Dalek Dave 11-Oct-11 3:15am    
Good Call.
C#
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "close page", "<script>window.close();</script>", false);
 
Share this answer
 
v2
if script manager is present in your page the above code you wrote will not work all the time
try this it works fine for me if script manager exist in the page

XML
string script = "<script language='javascript'>window.close();</script>";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script, false);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900