Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / January 2007



Tip: Looking for answers? Try searching our database.

passing variable in from 1 asp file to another

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LetMeDoIt - 05 Jan 2007 03:50 GMT
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 - 05 Jan 2007 09:10 GMT
> Greetings,
> there are tons of examples of how to pass a variable from one asp file
[quoted text clipped - 15 lines]
> </form>
> </body>

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 clipped - 3 lines]
> strSearch = Request.Form( "assetVar" )
> Response.Write ( "Request.Form: " & strSearch & "<br>" )

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

> 'strSearch = Request.QueryString( "assetVar" )

If you uncomment this line the strSearch would be CAR or BOAT since the
assetVar is in the querystring.
Daniel Crichton - 11 Jan 2007 15:03 GMT
LetMeDoIt wrote  on 4 Jan 2007 19:50:36 -0800:

> Greetings,
> there are tons of examples of how to pass a variable from one asp file
[quoted text clipped - 30 lines]
> %>
> </body>

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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.