Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Response.Write and Response.Redirect

Reply
Thread Tools

Response.Write and Response.Redirect

 
 
Sehboo
Guest
Posts: n/a
 
      12-09-2003
On my ASP page, when I click a button, I want to do three things:

1. Check for some values.
2. Open a new window and pass some values as query string.
3. Redirect to some other page

Here is the code:

If (sServiceCenter = "*ALL") Then
sServiceCenter = "%"
End If

Dim scriptString As String = "<script language=""javascript"">"
scriptString = scriptString &
"mywindow=window.open('SBNIList.aspx?ServiceCenter =" & sServiceCenter
& _
"','_new','width=screen.width,height=screen.height ,resizable=yes,status=no,toolbar=no,menubar=no,lef t=0,top=0,scrollbars=yes');</script>"

Response.Write(scriptString)
Response.Redirect("SBNIDone.aspx")

But it doesn't work. It just simply redirects and doesn't open the
new window. If I comment out the redirect line then it opens up the
new window.

Any idea?
 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      12-09-2003

"Sehboo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> On my ASP page, when I click a button, I want to do three things:
>
> 1. Check for some values.
> 2. Open a new window and pass some values as query string.
> 3. Redirect to some other page
>
> Here is the code:
>
> If (sServiceCenter = "*ALL") Then
> sServiceCenter = "%"
> End If
>
> Dim scriptString As String = "<script language=""javascript"">"
> scriptString = scriptString &
> "mywindow=window.open('SBNIList.aspx?ServiceCenter =" & sServiceCenter
> & _
>

"','_new','width=screen.width,height=screen.height ,resizable=yes,status=no,t
oolbar=no,menubar=no,left=0,top=0,scrollbars=yes') ;</script>"
>
> Response.Write(scriptString)
> Response.Redirect("SBNIDone.aspx")
>
> But it doesn't work. It just simply redirects and doesn't open the
> new window. If I comment out the redirect line then it opens up the
> new window.
>
> Any idea?


You can't both send output and redirect. An HTTP Redirect is like saying
"there is no
content here, try there", so the browser should ignore anything that was
sent anyway.
Maybe ASP.Net also any response text that was generated.

Solution: put the redirect in with the script that you were already sending.

Hans Kesting


 
Reply With Quote
 
 
 
 
Craig
Guest
Posts: n/a
 
      12-09-2003
Hans is mostly right, but there's a way to do what you're wanting... You
can't use Response.Redirect, instead you need to use the HTML REFRESH
metatag because it allows the page to actually display and then redirect
after a specified time period.

So, use Response.Write (or whatever method you want) write out to the new
page whatever you want to display and add the refresh metatag with a 10
second delay or whatever, you're set.


"Hans Kesting" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Sehboo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > On my ASP page, when I click a button, I want to do three things:
> >
> > 1. Check for some values.
> > 2. Open a new window and pass some values as query string.
> > 3. Redirect to some other page
> >
> > Here is the code:
> >
> > If (sServiceCenter = "*ALL") Then
> > sServiceCenter = "%"
> > End If
> >
> > Dim scriptString As String = "<script language=""javascript"">"
> > scriptString = scriptString &
> > "mywindow=window.open('SBNIList.aspx?ServiceCenter =" & sServiceCenter
> > & _
> >

>

"','_new','width=screen.width,height=screen.height ,resizable=yes,status=no,t
> oolbar=no,menubar=no,left=0,top=0,scrollbars=yes') ;</script>"
> >
> > Response.Write(scriptString)
> > Response.Redirect("SBNIDone.aspx")
> >
> > But it doesn't work. It just simply redirects and doesn't open the
> > new window. If I comment out the redirect line then it opens up the
> > new window.
> >
> > Any idea?

>
> You can't both send output and redirect. An HTTP Redirect is like saying
> "there is no
> content here, try there", so the browser should ignore anything that was
> sent anyway.
> Maybe ASP.Net also any response text that was generated.
>
> Solution: put the redirect in with the script that you were already

sending.
>
> Hans Kesting
>
>



 
Reply With Quote
 
Sehboo
Guest
Posts: n/a
 
      12-10-2003
Actually I found out the solution after I posted this question:

Instead of Response.Redirect, I needed to do server.transfer. It works now.

Thanks for the responses though.

"Craig" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> Hans is mostly right, but there's a way to do what you're wanting... You
> can't use Response.Redirect, instead you need to use the HTML REFRESH
> metatag because it allows the page to actually display and then redirect
> after a specified time period.
>
> So, use Response.Write (or whatever method you want) write out to the new
> page whatever you want to display and add the refresh metatag with a 10
> second delay or whatever, you're set.
>
>
> "Hans Kesting" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > "Sehboo" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > On my ASP page, when I click a button, I want to do three things:
> > >
> > > 1. Check for some values.
> > > 2. Open a new window and pass some values as query string.
> > > 3. Redirect to some other page
> > >
> > > Here is the code:
> > >
> > > If (sServiceCenter = "*ALL") Then
> > > sServiceCenter = "%"
> > > End If
> > >
> > > Dim scriptString As String = "<script language=""javascript"">"
> > > scriptString = scriptString &
> > > "mywindow=window.open('SBNIList.aspx?ServiceCenter =" & sServiceCenter
> > > & _
> > >

> >

> "','_new','width=screen.width,height=screen.height ,resizable=yes,status=no,t
> > oolbar=no,menubar=no,left=0,top=0,scrollbars=yes') ;</script>"
> > >
> > > Response.Write(scriptString)
> > > Response.Redirect("SBNIDone.aspx")
> > >
> > > But it doesn't work. It just simply redirects and doesn't open the
> > > new window. If I comment out the redirect line then it opens up the
> > > new window.
> > >
> > > Any idea?

> >
> > You can't both send output and redirect. An HTTP Redirect is like saying
> > "there is no
> > content here, try there", so the browser should ignore anything that was
> > sent anyway.
> > Maybe ASP.Net also any response text that was generated.
> >
> > Solution: put the redirect in with the script that you were already

> sending.
> >
> > Hans Kesting
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments