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

Another simple question - passing variables

P: n/a
I have another hopefully simple question. I am so used to writing VB .Net
windows apps that there are some things in ASP .Net that just does not easily
cross over. I know how to pass variables to another form, but how would I do
this from one page to another? I am not finding a simple solution.

Thanks for the help
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Brad,

You can use ApplicationState, SessionState, ViewState, or
Cookies to share data in different pages of one
application.

HTH

Elton Wang
el********@hotmail.com

-----Original Message-----
I have another hopefully simple question. I am so used to writing VB .Netwindows apps that there are some things in ASP .Net that just does not easilycross over. I know how to pass variables to another form, but how would I dothis from one page to another? I am not finding a simple solution.
Thanks for the help
.

Nov 19 '05 #2

P: n/a
I did find something and it seems to be working:

1. In your SendingPage.aspx add an item to the context.
Dim variableToPass as String = "Passed Value"
Context.Items.Add("variableToPass", variableToPass)

2. In your SendingPage.aspx call Server.Transfer to transfer to your
ReceivingPage.aspx.
Server.Transfer("ReceivingPage.aspx", True)

3. In your ReceivingPage.aspx retrieve the variable from the context.
Dim receivedValue As String
receivedValue = Context.Items("variableToPass")
Nov 19 '05 #3

P: n/a
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Brad" <Br**@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
I have another hopefully simple question. I am so used to writing VB .Net
windows apps that there are some things in ASP .Net that just does not
easily
cross over. I know how to pass variables to another form, but how would I
do
this from one page to another? I am not finding a simple solution.

Thanks for the help

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.