Saturday, March 24, 2012

Pass Variables from one page to another

is there a way to pass variables from one page to another.
I created one page where the user makes selections by ddl and textboxes. I want to be able to pass the selections to a second page of a datalist to display the results.

thanksStore the values of the variables in session variables. You can then access them on your second page.
Request.Form is still available.
what do you mean request.Form is still available?
what do you mean session variables?
Request.Form["TheNameOfYourFormField"] will give you the values of your fields, like in ASP.
Request.Form would only work (as far as I am aware) if you your posting page is an HTML form and not a web form, a web form will overide the form action attribute and postback. Is this right?

Use session like this:

Session("MyValue") = "xxx" 'sets your value

Dim MyValue As String = Session("MyValue") 'gets the value back on another page

or look at this method that I quite like -MSDN passing values between web forms pages

Simon

0 comments:

Post a Comment