467,926 Members | 1,470 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

Another simple question - passing variables

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
  • viewed: 1197
Share:
3 Replies
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
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
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.

Similar topics

188 posts views Thread by christopher diggins | last post: by
2 posts views Thread by Ed Jay | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.