Saturday, March 24, 2012

passign variables from one page to another

If I have variables that I need passed to the next page I want to display, how should I do that?
I was doing it with session variables, but I really don't need them to be part of the session, just there long enough to load the next page.
I tried hardcoding something like
Responce.Redirect("NextPage.aspx?Name="+strName);
but I don't know how to pick it up on the next page. I tried with the viewstate but It never finds it?

Can someone explain to me, or pont to an article how I should be doing this..
ThanksIf you did want to take the querystring approach (i.e. "nextpage.aspx?name=....") then you can retrieve your values out of the querystring like so:

Dim strName As String = Request.QueryString("Name")

Storing your values in ViewState won't help you on the next page because ViewState is a page-by-page storage medium, not a page-to-page storage medium.
Ok thanks, Is the queryString approach generally the most common used? What other ways are there to do this?

0 comments:

Post a Comment