So I have a webapplication where I select a value from a dropdownlist. When this value is selected, I want to load another page in a new window.
I tried this:
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('Default.aspx', '_blank');", true);
It does open the page, but not in a new window/tab. It opens it in the current opened page.
Alternatively I tried:
ClientScript.RegisterStartupScript(this.GetType(), "OpenWin", "<script>openDashboardPage()</script>");
and
HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>window.open('Default.aspx', '_new');</SCRIPT>");
They all behave in the same fashion. I just loads the page in the existing window. I tried it in both Firefox and Chrome, thinking it might be a browser thing, but they both behaved the same.
How do I open a new window?
string url = "D13. aspx"; string s = "window. open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');"; ClientScript. RegisterStartupScript(this.
Hold Ctrl and left-click or middle-click the Reload button on the location/address bar to open the current page in a new tab.
When the Button is clicked, first the SetTarget JavaScript function is called inside which the target property of the Form is set to _blank and after that the Server Side function is executed. Inside the Button Click event handler, the Response. Redirect code is executed and the Page opens in new Tab.
Try this one
string redirect = "<script>window.open('http://www.google.com');</script>";
Response.Write(redirect);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With