Groups | Blog | Home
all groups > inetserver asp db > january 2007 >

inetserver asp db : passing variable in from 1 asp file to another



LetMeDoIt
1/4/2007 7:50:36 PM
Greetings,
there are tons of examples of how to pass a variable from one asp file
to another in this group, and yet I cannot seem to get that right.
Seems that the variable that I'm passing is always blank in the
destination file. Any help is greatly appreciated. Here's my logic:

In file SetVar.asp, I'm passing a variable named assetVar.
In file ReadVar.asp I'm trying to read that variable. This is where I
having the issue. Note that in ReadVar.asp, I'm using the 3 Request
calls for lack of knowing better.

The code for setting the variable is in SetVar.asp:
<body>
<form method="POST" >
<br><a href="ReadVar.asp?assetVar=CAR" target="detail"><b>CAR</b></a>
<br><a href="ReadVar.asp?assetVar=BOAT"
target="detail"><b>BOAT</b></a>
</form>
</body>
....

The code for reading the vairiable is in ReadVar.asp and follows:
<%
Dim strSearch
strSearch = Request.Form( "assetVar" )
Response.Write ( "Request.Form: " & strSearch & "<br>" )

'strSearch = Request.QueryString( "assetVar" )
Response.Write ( "Query.Form: " & strSearch & "<br>" )

'strSearch = Trim(Request( "assetVar" ))
Response.Write ( "Query.Form: " & strSearch & "<br>" )
%>
</body>
Anthony Jones
1/5/2007 9:10:39 AM

[quoted text, click to view]

Not sure why you place the anchors above inside a form element. As it is
the form element is doing nothing at all

[quoted text, click to view]

strSearch is blank because there is no form post in progress only a GET for
the URL:-
ReadVar.asp?assetVar=CAR OR ReadVar.asp?assetVar=BOAT

[quoted text, click to view]

If you uncomment this line the strSearch would be CAR or BOAT since the
assetVar is in the querystring.


Daniel Crichton
1/11/2007 3:03:27 PM
LetMeDoIt wrote on 4 Jan 2007 19:50:36 -0800:

[quoted text, click to view]

In a form post, variables will be in the .Form collection. However, you're
using URLs (the form tags are a complete waste of time as you have no form
elements), so the variables will be in the QueryString collection. If you'd
uncommented the two lines in your ReadVar.asp code you'd have seen this.
Drop the form tags, change your code to use Request.QueryString, and it'll
work fine.

Dan

AddThis Social Bookmark Button