How can I pass variables or values from one asp.net vb.net code page to another?

mHo2 picture mHo2 · Jul 12, 2012 · Viewed 21.6k times · Source

I have a site/portal created in ASP.net and VB.net.

I want to know how to reference variables between two asp pages, but not the pages themselves, I want to directly transfer data from the .aspx.vb bit of the page to another pages .aspx.vb file. Is that possible?

Answer

Matt picture Matt · Jul 12, 2012

An easy way in asp.net/VB.net is to use session variables.

Session("myVariable") = "blah"

From another .aspx.vb page you can now use this value. Example:

Dim strTest as String = ""
strTest = Session("myVariable")

You can access this page on any of your .aspx pages for this session by referencing Session("myVariable")