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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a variable using the address bar

Status
Not open for further replies.

iainmc

Programmer
Dec 2, 2002
53
GB
I am trying to pass a value from one page to the next on my web site and had heard that i can do this as part of the page address.

Does anyone know how this works and could give me a quick explanantion of how i do this?

Muchos appreciated
 
Passing values from the address bar is pretty easy and makes page redirection great on single-page layouts.

Below I've pasted the coding for a menu system I have on one of our pages.

To being, you need to actually put the variable in your link. For the examples below. When I want to go to the Forum, I would put the link as "default.asp?fourm". Same for the rest of the examples. This page uses the query strings to dynamically create pages. I have a single 'default.asp' page with the layout, and the content is separated out into separate, smaller files; allowing for portability amongst our Inter and Intranets.

See the explainations below for what the coding does.

<!--Begin ASP menu system -->
<% Dim q
q = Request.querystring
Select Case q
%>

Above is what pulls the address bar information. You create your variable, pull the querystring (ASP function) into the variable, and then begin a Select Case to handle your variables and redirections.

<% Case &quot;home&quot; %>
<!-- #include file=&quot;inc/frontpage.htm&quot; -->

ASP is great that it is so close to Visual Basic. Above is a standard Basic Select Case statement. If querystring, or q, equals 'home', then do an include for the file, or whatever action you are needing to do (e.g. redirection, manulipulating the variable from a form, so on.)

<% Case &quot;forum&quot; %>
<% response.Redirect(&quot;forum/default.asp&quot;) %>

<% Case &quot;event_calendar&quot; %>
<!-- #include file=&quot;inc/e_cal.htm&quot; -->

<% Case &quot;sts_chat&quot; %>
<!-- #include file=&quot;inc/csc_chat.htm&quot; -->

<% Case &quot;submit_wo&quot; %>
<!-- #include file=&quot;inc/submit_wo.asp&quot; -->

<% Case Else %>
<!-- #include file=&quot;inc/frontpage.htm&quot; -->

<% End Select %>
<!--End ASP menu system -->
As above, you end your Select Case statement.

The following link from Microsoft provides great information on using multiple query strings.


Hope this helps!

-David



David R. Longnecker
CCNA, MCSA, Network+, A+
Management Information Services
Wichita Public Schools, USD 259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top