wsyeager Posted August 30, 2003 Posted August 30, 2003 After using Server.Transfer to transfer data from one page to another, I would like to know if there is a way to keep the receiving web page variables intact after a postback. Here is the code from the "sending" page: <code> Public ReadOnly Property SelectedDate() As Date Get Return Calendar1.SelectedDate End Get End Property . . . Server.Transfer("SignUp.aspx") </code> Here is the code in the receiving page: <code> Protected SelectedDate As Date Public clsCalendar As Calendar . . . Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then clsCalendar = CType(Context.Handler, Calendar) SelectedDate = clsCalendar.SelectedDate Session.Item("dteSelectedDAte") = CType(SelectedDate, Date) End Sub </code> I am forced to place the property SelectedDate into a Session variable (Session.Item("dteSelectedDAte") = CType(SelectedDate, Date) ) because after the postback, I lose access to the receivning varaible (SelectedDate) which was transferred from the original page. Now, however, after a postback, the sending page is the same page, not the original. It's no big deal. I would just like to know if this is the way it supposed to work... Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Moderators Robby Posted August 31, 2003 Moderators Posted August 31, 2003 You can use the Context.Handler without resorting to the session objects. Quote Visit...Bassic Software
wsyeager Posted September 1, 2003 Author Posted September 1, 2003 Yes, that's true, but after postback you lose reference to the Context.Handler, forcing you to place any of the variables in session state, etc. Using the Context.Hanlder seems great for one time page usage on passing values to the receiving page. Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
*Gurus* Derek Stone Posted September 1, 2003 *Gurus* Posted September 1, 2003 Passing the variable to the receiving page via its query string would make the most sense. Session state really wasn't meant for such a use. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.