Passing a value to another page

M

Mike P

When you are passing a value to another page, and will need access to it
throughout the page and on any postbacks, what is the best way to store
it? By making it a variable accessible to the whole page, or by putting
it in the ViewState?


Thanks,

Mike
 
G

Guest

Store it in the ViewState. Keeping in a page-wide variable will not get the
value on postbacks.
 
P

Paul Gielens

Hi Mike,

In .NET 1.0/1.1 you can choose between QueryString, Session or
Server.Transfer. I recommend Session (it's just a matter of taste). In .NET
2.0 you use the PostBackUrl property on your controls. By setting the
PostBackUrl="/My2Page.aspx" in your Button tag the user will, when clicked,
be redirected to the My2Page.aspx in which you can access your values using
Request.Form.

Best regards,
Paul Gielens

Visit my blog @ http://weblogs.asp.net/pgielens/
###
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top