473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Confusion about using Server.Transfer.

I have Page1 that does a transfer to page2. When the user is done with
Page2, there is a button on Page2 that they can press to bring them back to
Page1. I use Server.Transfer to navigate from one page to the next.

The confusion that I am having is that when the user is done with Page2 and
clicks on the button to bring them back to Page1, I want Page1 to basically
come back with the exact same view that it had before the user navigated
away from it. However, I notice that when Page1 comes back, the
Page.IsPostback is set back to false, so all of my initialization code gets
run. I also notice that my ViewState is gone. I was hoping that somehow
the return trip back to the original page would behave something like a
postback with the original Page1 ViewState intact.

Maybe I am just not understanding how to do this correctly, but it seems
like it should be pretty trivial to return back to a page as with its
original state intact. The only other option I would have is to call
JavaScript to navigate backwards in the history buffer, but that just
doesn't seem right.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Nov 19 '05 #1
3 1522
Hi Ken:

ViewState is only effective when a form posts back to itself - in this
scenario Page2 doesn't know how to write out the ViewState for Page1.

I imagine your button is a hyperlink? You'll have to carry state
across the pages by passing information in the querystring, or holding
state on the server, like in the Session or Cache.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 11:26:16 -0400, "Ken Varn" <nospam> wrote:
I have Page1 that does a transfer to page2. When the user is done with
Page2, there is a button on Page2 that they can press to bring them back to
Page1. I use Server.Transfer to navigate from one page to the next.

The confusion that I am having is that when the user is done with Page2 and
clicks on the button to bring them back to Page1, I want Page1 to basically
come back with the exact same view that it had before the user navigated
away from it. However, I notice that when Page1 comes back, the
Page.IsPostback is set back to false, so all of my initialization code gets
run. I also notice that my ViewState is gone. I was hoping that somehow
the return trip back to the original page would behave something like a
postback with the original Page1 ViewState intact.

Maybe I am just not understanding how to do this correctly, but it seems
like it should be pretty trivial to return back to a page as with its
original state intact. The only other option I would have is to call
JavaScript to navigate backwards in the history buffer, but that just
doesn't seem right.


Nov 19 '05 #2
It's my understanding that if I use Server.Transfer(NewUrl,true), then my
forms QuerryString is passed to the new page, and I have confirmed that it
does. The problem I am having, is there should be some way of having that
postback data available if I transfer back to the original page, which I
can't seem to figure out how to do. Somehow I need something like this
(although I know this is not how to do it):

Server.Transfer(OrigUrl, SavedFormPostbackData);

Since the postback data is transferred to the new page, one would think that
there would be a way to transfer it back to the calling page.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:3o********************************@4ax.com...
Hi Ken:

ViewState is only effective when a form posts back to itself - in this
scenario Page2 doesn't know how to write out the ViewState for Page1.

I imagine your button is a hyperlink? You'll have to carry state
across the pages by passing information in the querystring, or holding
state on the server, like in the Session or Cache.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 11:26:16 -0400, "Ken Varn" <nospam> wrote:
I have Page1 that does a transfer to page2. When the user is done with
Page2, there is a button on Page2 that they can press to bring them back toPage1. I use Server.Transfer to navigate from one page to the next.

The confusion that I am having is that when the user is done with Page2 andclicks on the button to bring them back to Page1, I want Page1 to basicallycome back with the exact same view that it had before the user navigated
away from it. However, I notice that when Page1 comes back, the
Page.IsPostback is set back to false, so all of my initialization code getsrun. I also notice that my ViewState is gone. I was hoping that somehow
the return trip back to the original page would behave something like a
postback with the original Page1 ViewState intact.

Maybe I am just not understanding how to do this correctly, but it seems
like it should be pretty trivial to return back to a page as with its
original state intact. The only other option I would have is to call
JavaScript to navigate backwards in the history buffer, but that just
doesn't seem right.

Nov 19 '05 #3
Ken:

Sounds like a problem I just figured out. I needed to to open a page in a
separate window, while preserving the original page. Try the code below.
When the user is done with Page2, just close it.
--
Mike Salter
(just another programmer)

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
...
string strBaseUrl = Request.Url.AbsoluteUri;
strBaseUrl = strBaseUrl.Substring(0,strBaseUrl.LastIndexOf("/") + 1);
Session["BaseURL"] = strBaseUrl;
...
}
}

// Somewhere in your code you decide to show Page2
string strBaseUrl = Session["BaseURL"].ToString();
System.Web.HttpContext.Current.Response.Write("<sc ript
language=javascript>window.open('"
+ strBaseUrl
+ "Page2.aspx','new_Win');</script>");
"Ken Varn" <nospam> wrote in message
news:ug***************@TK2MSFTNGP12.phx.gbl...
I have Page1 that does a transfer to page2. When the user is done with
Page2, there is a button on Page2 that they can press to bring them back
to
Page1. I use Server.Transfer to navigate from one page to the next.

The confusion that I am having is that when the user is done with Page2
and
clicks on the button to bring them back to Page1, I want Page1 to
basically
come back with the exact same view that it had before the user navigated
away from it. However, I notice that when Page1 comes back, the
Page.IsPostback is set back to false, so all of my initialization code
gets
run. I also notice that my ViewState is gone. I was hoping that somehow
the return trip back to the original page would behave something like a
postback with the original Page1 ViewState intact.

Maybe I am just not understanding how to do this correctly, but it seems
like it should be pretty trivial to return back to a page as with its
original state intact. The only other option I would have is to call
JavaScript to navigate backwards in the history buffer, but that just
doesn't seem right.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
5
by: Julien C. | last post by:
Hi all, I have an "EditeItem.aspx" page which lets me edit properties of an "Item". In the OnClick() event of my Save button, I do save Item changes to the database and then I redirect the user...
1
by: Terry Mulvany | last post by:
Grettings, Normally I can use Request.RawUrl to get the 'current' page (amongst many other things). But in the case of using a Server.Transfer but the path from the root of the site . So if...
2
by: J'son | last post by:
Ok, thanx in advance for all who can help me. I've coded in ASP for years, but am new to ASP.NET. I have a small ecommerce store im migrating over to ASP.NET (C#) and I am confused about this tag:...
11
by: Alexander Bosch | last post by:
Hi, I'm having a problem similar to the one that's stated in this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;839521 When I'm posting a page to itself with the bool value as true it...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
1
by: bev a | last post by:
HI - I am coding in access 2003 - but the database is in access 2000 format. I have a 'menu' form that contains buttons that transfer the user to other databases in the system. I am using VBA to do...
5
by: John Salerno | last post by:
I'm experimenting with this now and I'm a little confused about transferring commands. This might be more of an FTP question than strictly Python, but it's still related to how to use the ftplib...
1
by: Henry | last post by:
Hello I'm using server.transfer() to navigate between pages, and I don't understand why the URL changes while navigating. My start page is default.aspx and from a button I want to navigate to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.