suleman altaf

suleman altaf

  • NA
  • 3
  • 1.6k

Browser window opens on every postback IE

Jun 30 2013 1:27 AM
0 down vote favorite
    

I've been working on an asp.net website, where i need to open a browser window from c# code behind. I created the following JS on aspx page.

JS:

function openPopUp() { window.open("About.aspx?something=happening", "WindowPopup", "width=700px, height=500px, resizable"); }

and this C# code

C#:

protected void Button1_Click(object sender, EventArgs e) { string script = "Sys.Application.add_load(openPopUp);"; ClientScript.RegisterStartupScript(this.GetType(), "openPopUp", script); }

The above code works fine, and shows the About.aspx page as a new browser window. But, the problem is whenever the parent page does a postback(e.g. whenever i try to sort the radgrid on parent page), it opens the browser window again.

I've googled it, but didn't found helpful workaround to this problem, maybe i would need to unregister the client script which is being registered on Button1_Click, if so then lemme know how can i detach or unregister the script once the browser window is closed so that the same browser window doesn't shows again and again on each postback.

any help would be highly appreciated!
<b></b>

Answers (3)