Passing values to another web page

  • Thread starter Thread starter RipperT
  • Start date Start date
R

RipperT

College newbie here (Instructor MIA). I have instructions to pass variable
values from one web page to another like this (VS2005):

1. Declare and create the properties on the first page (source form):
Public ReadOnly Property UserName() As String
Get
Return userNameTextBox.Text
End Get
End Property
2. Call the next page by calling the Transfer method of the Server object:
Private Sub pageTwoButton_Click(...)
Server.Transfer("secondWebForm.aspx")
End Sub
3. In the Page_Load event of the second page, create an instance of the
source page and retrieve the property values from the instance:
Public originalPage As WebForm
Private userName As String
Private Sub Page_Load(...)
If Not IsPostBack() Then
originalPage = CType(Context.Handler, firstWebForm)
userName = originalPage.UserName 'Retrieve the value
userLabel.Text = userName 'Preserve for future postbacks
End If
End Sub

Question: How is 'Public originalPage As WebForm' a declaration of an
instance of the first page? I can't even find WebForm as a valid type
declaration.

Many thanx,

Rip
 
Ripper,

I never succeeded to pass to another page. Remember that a page is
stateless, therefore it does not exist anymore on your server as soon as it
is send.

Most people use the long time existing Session.Items for that.

There is as well another method, but for me the Sessions.Item did it the
best.

Cor
 
Thanks for the response. Our instructions mentioned the use of
Session.Items, but did not include details on how to use it. Can you provide
an example?

Many thanks,

Ripper
 
Ripper,

Just use it, to transport a dataset it is by instance

session.Item("ds") = ds

And to use it in your other page
ds as dataset = DirectCast(session.Item("ds"),DataSet)

Cor
 
Thank you for the help.

Rip

Cor Ligthert said:
Ripper,

Just use it, to transport a dataset it is by instance

session.Item("ds") = ds

And to use it in your other page
ds as dataset = DirectCast(session.Item("ds"),DataSet)

Cor
 
Back
Top