Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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...

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted

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.

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...