By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Redirect to multiple pages without displaying each page...

P: n/a
Hi all :-)

I need to redirect to multiple pages on click of a transmit button, without
redisplaying each page. This redirection is to capture session variables
that are created on each page and pass them to the main page to be
displayed. We are actually NOT using session variables, but storing the
values in a temporary table. The problem is that the values don't get
stored in the temporary table unless the user goes to each page individually
to view it, and then goes to the "Summary" page where all the values are
displayed. If the user does not go to each page first, the values won't
appear in the summary. I need a way to cycle through those pages behind the
scene, with out the user having to view each page individually. Can any one
help me with a suggestion or example on how to do this? Any help is much
appreciated.

Thanks,

Coleen
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hello...

I would probably try Server.Transfer or Response.Redirect and on the
page load have it call what needs to be done and move to the next page.

If the pages are used by others possibly pass a flag in the query
string or form values etc...to distinguish that the page is to be
redirected.

Marc Cramer

Nov 21 '05 #2

P: n/a
Actually, Marc, we are using the response.redirect, but how do you make the
page that is called not display, and close it after the values are passed?
We don't want the users to have to "look" at the page if they go directly to
the summary page without checking all the pages that do the calculations
first. Dumb question, but what exactly is a Server.Transfer event, and how
does it work? I've never used that before...

Thanks for your help!

Coleen

"Marc Cramer" <cr*******@comcast.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hello...

I would probably try Server.Transfer or Response.Redirect and on the
page load have it call what needs to be done and move to the next page.

If the pages are used by others possibly pass a flag in the query
string or form values etc...to distinguish that the page is to be
redirected.

Marc Cramer

Nov 21 '05 #3

P: n/a
Hello...

Not a dumb question at all.

quoted from msdn help
"You may want to redirect users from one Web Forms page to another
page. You might do this to display a page that is matched to the user's
browser capabilities or is written in the language that the user
speaks.

There are two ways to redirect pages:

Using a server-side method. In this scenario, the server simply
transfers the context to another page. The advantage is that you can
share page context information between pages. The disadvantage is that
the user's browser does not know about the transfer, so the browser's
history is not updated. If the user refreshes the page, unexpected
results can occur.

Using the browser. In this scenario, you send a command to the user's
browser that causes the browser to fetch a different page. The
advantage is that the browser's history is updated. The disadvantage is
that this scenario performs an extra round trip, which can affect
performance."
From my experience using Server.Transfer you can pass the form

submission from page to page but the URL displayed in the browser is
not changed to reflect the page they were transferred to, while with
Response.Redirect you have to handle the form submission on each page
or it is lost, but the URL is updated to reflect where they are...

Just a reminder:
if using cookies the values to be stored are not set on the client
until the page has been sent...
so could run into problems if transfer, set value, transfer and try to
read value prior to page postback
This happens because the client cookie hasn't been updated yet since
the page hasn't gone to the client and updated the cookie

I suggest trying the Server.Transfer() to go page to page but on the
page that is immediately prior to your final page do a
Response.Redirect so that the URL matches and if they press back in the
browser they will be taken to the original starting page.
Make sense?

Marc

Nov 21 '05 #4

P: n/a
Hello,

Sorry I missed the first question about not displaying the page...
try something like this

C#
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(Page.IsPostBack==false)
{
// check to see if we have our flag to indicate auto redirect...
if(Request.QueryString["Flag"]!=null)
{
// call the processing methods here...
DoStuff();
// go to next page...
Response.Redirect("NextPage.aspx", true);
}
// we got here so handle as a normal diplayed page...

}
}

VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Page.IsPostBack = False Then
' check to see if we have our flag to indicate auto redirect...
If Not Request.QueryString("Flag") Is Nothing Then
' call the processing methods here...
DoStuff()
' go to next page...
Response.Redirect("NextPage.aspx", True)
End If
' we got here so handle as a normal diplayed page...
End If
End Sub

Marc

Nov 21 '05 #5

P: n/a
Actually, this looks more like what I want to do...we want the
redirect/transfer to be transparent to the user. So, in that case we would
not want the URL to display the page that it was being redirected to. That
makes perfect sense - thanks SO much! I really appreciate your help, and
since I've read both of your return posts, thanks for the code to keep my
pages from displaying too! Have a very Merry Christmas - Cheers :-)

Coleen
"Marc Cramer" <cr*******@comcast.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello...

Not a dumb question at all.

quoted from msdn help
"You may want to redirect users from one Web Forms page to another
page. You might do this to display a page that is matched to the user's
browser capabilities or is written in the language that the user
speaks.

There are two ways to redirect pages:

Using a server-side method. In this scenario, the server simply
transfers the context to another page. The advantage is that you can
share page context information between pages. The disadvantage is that
the user's browser does not know about the transfer, so the browser's
history is not updated. If the user refreshes the page, unexpected
results can occur.

Using the browser. In this scenario, you send a command to the user's
browser that causes the browser to fetch a different page. The
advantage is that the browser's history is updated. The disadvantage is
that this scenario performs an extra round trip, which can affect
performance."
From my experience using Server.Transfer you can pass the form

submission from page to page but the URL displayed in the browser is
not changed to reflect the page they were transferred to, while with
Response.Redirect you have to handle the form submission on each page
or it is lost, but the URL is updated to reflect where they are...

Just a reminder:
if using cookies the values to be stored are not set on the client
until the page has been sent...
so could run into problems if transfer, set value, transfer and try to
read value prior to page postback
This happens because the client cookie hasn't been updated yet since
the page hasn't gone to the client and updated the cookie

I suggest trying the Server.Transfer() to go page to page but on the
page that is immediately prior to your final page do a
Response.Redirect so that the URL matches and if they press back in the
browser they will be taken to the original starting page.
Make sense?

Marc

Nov 21 '05 #6

P: n/a
Glad to help.
Have a Merry Christmas also.

Marc

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.