Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting a value from 1 program to another

Status
Not open for further replies.

lwfg

Programmer
Feb 9, 2009
52
US
I am trying to get values from masterpage.master to page2.aspx.

On page_load of the master page, a,b are assigned in a script written in vb. In the master page's form, there's a link to page2.aspx and I want those values to be sent to page2 when the link is clicked.

<a href="page2.aspx?a=3&b=2">page2</a> works but only with literal vals like 2 and 3. How can values assigned in the vb script be put in that expression?

To know I can get hold of those values to page2, I have a script that runs on page_load of page2 that says in it: response.write(request.querystring("a")).

1. How do I send a,b along with the url and get hold of them in a vb script that runs when page2 loads ?
2. How else can this be done ?

Thanks.
 
I think you are asking how to build a dynamic querystring?
Use a stringbuilder and generate the string you want:
Code:
'HTML
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>

'Page 1
Dim sb as new stringbuilder
sb.append("href=page2.aspx?a=" + YourFirstValue)
sb.append("&b=" + YourSecondValue)
Then assign that to your link(use a server side HyperLink:
Me.HyperLink1.NavigateURL = sb.tostring

'Page2
Get the querystingvalues using request.querystring


 
Thank you very much.

I think this will help me carry user information from page to page instead of using session variables.
 
Session variables are fine as long as you don't store lots of info in them, or have a lot of them. This depends on the amount of memory on the server, so sometimes it will not even matter.

Sessions are also better than querystring variables if you don't want some info to be seen by the user, although you can rewrite the URL as well.
 
What do you mean by rewrite the url?

I'd prefer using session vars but have had these problems with them:
1. On a machine with Visual Studio 2008:
-Session vars appear not to get assigned.
-Cache and application variables seem to work ok.
2. On another machine without Visual Studio:
-Session, cache, and application vars disappear after a while.

I found out things other than the application pool resetting can cause this. This article lists some
Most of this is above my head.

If you have any advice on how to keep session variables from
going away, I would be grateful for it. Same for application and cache.
 
Look into URL rewriting

As for the other problem, the app pool is being reset, so you will have to find out why that is happening. Research online.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top