PDA

Click to See Complete Forum and Search --> : Redirect to URL in a new window?


simonm
Apr 19th, 2005, 10:21 AM
In VB.NET code in an ASP.NET project, I can call:
Response.Redirect("NewPage.apsx")
And this directs me to "NewPage.aspx" in my current browser window. But how can I open this URL in a new window rather than the current one?

GlenW
Apr 19th, 2005, 10:30 AM
You can only open a new window client-side, so send a javascript inline command via the buffer.

simonm
Apr 19th, 2005, 10:33 AM
That's ridiculous!?!

My form is serverside, therefore all my controls are serverside. You mean I can't possibly open in a new window then?

GlenW
Apr 19th, 2005, 10:36 AM
Sorry that's the way it is, but sending inline javascript only takes a couple of lines of code.

simonm
Apr 19th, 2005, 10:37 AM
Sorry that's the way it is, but sending inline javascript only takes a couple of lines of code.
Can I do that from a webcontrol button that is run at the server?

GlenW
Apr 19th, 2005, 10:40 AM
Yes just send the javascript via Response.Flush after putting the script in the Buffer.
Make sure you pad the buffer first 'cos it won't flush if its contents are too small and your script will be too small.

simonm
Apr 19th, 2005, 10:44 AM
Do you know if it works with vbscript?

Using the buffer is completely new to me...any code example would be greatly appreciated... :thumb:

GlenW
Apr 19th, 2005, 10:49 AM
Response.Write("<script language=javascript>window.open('PageToOpen.aspx',null, 'height=550, width=800, status=no, toolbar=no, menubar=no, location=no');</script>");
Response.Flush();

This is for javascript in C# shouldn't be too hard to port.

GlenW
Apr 19th, 2005, 10:50 AM
Also my syntax may be awry as haven't been able to test it.

simonm
Apr 19th, 2005, 10:51 AM
I see. Thankyou very much! :wave: