Use ScriptManager to close the EP page window

Using RegisterStartupScript we can write a JavaScript function in code behind and call it from code-behind. For example,  to close a page window, we can use the following code in .cs file:

protected void Button1_Click(object sender, EventArgs e)


     string closeWindowScript= "window.close()";
     ScriptManager.RegisterStartupScript(this, typeof(string), "CLOSE_WINDOW", closeWindowScript, true);


Hope it helps.

This entry was posted in 未分类. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s