Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.redirect to new browser window 2

Status
Not open for further replies.

guitarzan

Programmer
Apr 22, 2003
2,236
US
The asp project I'm working on has several forms (not using frames). When the user submits the form, it gets submitted to itself, where I do my validation. If any fields are invalid, I redisplay the html with error messages at the top. If all fields are valid, I do a response.redirect to display whatever other screen I need.

The code I'm working on now is a report generator... if fields are invalid, I want to redisplay the same page (like above). But if all fields are valid, I want to display the output in a new broswer window. Can I do this with a response.redirect?

Thanks!
 
with response.redirect, nope you cannot open a new window...

try using window.open() method of javascript...

-DNG
 
ok let me tell you the reason also...

Code:
It is not possible with response.redirect because frames and windows are client-side concepts. The server just don't knows about these concepts. so it wont be able to open either a new window or frame.

-DNG


 
no. You would need to do this client-side - probably with a little javascript.

You could include a variable in the querystring in the redirect that instructs the page to open a new window and then close the old window but I think that is the best you will be able to do.
Code:
Response.Redirect "myPage.asp?open=new"
%>
Code:
<html>
<head>
<%
If Request.QueryString("open") = "new" Then
  Response.Write "<script type=""text/javascript"">window.open('newPage.asp','',''); window.close();</script>"
End If
%>
</head>

Tony

Spirax-Sarco - steam traps control valves heat exchangers
Sun Villa - Luxury Florida accommodation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top