How do you use Response.Redirect to open a new browser window?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone help with how to use the Response.Redirect method to open a page
in a new instance of the browser. In this case it is a report. When the
user selects a report from a list then I want to display the report but when
they close the report the resport list window (browser) should stay open.
Any help would be greatly appeciated.
Thanks.
 
Response.Redirect() is server side action, which cannot open a new browser
window on user end. Alos, more and more anti-popup measures are applied to
newer browsers. Opening a new browser window should only be resulted in by
ned user's explicit action, such as lick a button/link...

You should use client side code (javascript) to open a new Window. Here is
an example:

Assume you have a server control "LinkButton1"

private void Page_Load(....)
{
if (!Page.IsPostBack)
{
LinkButton1.Attributes.Add("onclick","OpenNewWindow('http://mysite/mypage.aspx?ID=111');return
false;");
}
}

Then in the HTML source of the page, add following script in
<Header></Header>
<script language="javascript">
function OpenNewWindow(url)
{
var win;
win=window.open(url,"NewWindow",
"width=800,height=600,toolbar=0,status=1,resizable=1,scrollbars=1");
win.focus();
}
</script>
 
Back
Top