We are using ASP.NET Webforms (not MVC).
My question is this: Is it possible to open a new browser window using a postback and then some variety of Response.Redirect?
We are using ASP.NET Webforms (not MVC).
My question is this: Is it possible to open a new browser window using a postback and then some variety of Response.Redirect?
I have not come across instances where Response.Redirect can navigate opening a new window.
Here are a way of doing it not using Response.Redirect which you can try:
ScriptManager.RegisterStartupScript(this, typeof(string), "New_Window", "window.open( 'http://www.website.com', null, 'height=800,width=1280,status=yes,toolbar=yes,menubar=yes,location=no' );", true);
Short answer? No.
Long answer:
ASP.NET is a server side framework, whereas the concept of browser windows is a client side one. Response.Redirect
just ends up sending a Location: [whatever the new url is]
header as part of the output stream. It just happens that pretty much all browsers handle that header by loading up the url that's in that header.
The most pain-free way would be using javascript on the postback to open the new window, as outlined in JLC007's answer. Another possible option is using the target attribute on the rendered form.
Try this
ScriptManager.RegisterStartupScript(this, typeof(string), "openWindow",
"window.open( 'http://www.website.com', target="_blank",
'height=800,width=1280,status=yes,toolbar=yes,menubar=yes,location=no' );",
true);