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

Newbie question - How do I pass a parm to .asp file and then read it

Status
Not open for further replies.

WantsToLearn

Programmer
Feb 15, 2003
147
US
I'm new to ASP so please bear with me. I am creating a demo in VB6 (say items and BOMs) to show recursive calculations are working correctly. I ask the user how many items they want to process and then build an item list and associated BOM list for each item.

If they click View items it pops them into the Internet Explorer where it displays an HTML Items List in a table with a link to the corresponding BOM. The problem is that the link URL doesn't exist. Since this is a demo, I only want to create the BOM HTML file if they click it.

Here is what I have done so far:

A. Demo creates an Items.asp file with HTML to display Items List as described above.

B. Pseudo link anchor tag points to BOM.asp file which is passed in one argument like this:

<A HREF=&quot;<%BOM.asp?LineNumber%>&quot;>Associated BOM</A>

LineNumber is all that I need to create the BOM on the fly and display it. It will be 1, 2, 3, etc.

Here are my questions:

1. Do I have my anchor tag coded properly? The dummy BOM page displays properly as far as I can tell.

2. How do you extract the parameter which was passed into the asp file? I've used VB some and you can use Command to return the argument list.

I'm not afraid to do some digging if someone points me but since this is a demo with no guaranteed work out of it I would appreciate it if someone could post a little bit of working code to get me started.

Thanks!
 
The problem's in your anchor - specifically, the script block indicators in the href attribute. Yours looks like this:

Code:
<A HREF=&quot;<%BOM.asp?LineNumber%>&quot;>Associated BOM</A>

It should look like this:

Code:
<A HREF=&quot;BOM.asp?LineNumber=1&quot;>Associated BOM</A>

The &quot;<%%>&quot; bits indicate that the browser should attempt to parse script, in whatever the default scripting language is (usually JScript for client-side, VBScript for server-side in IE). Now, if oyu were in an ASP page and needed to pass a dynamic URL to your anchor, you could do it like this:

Code:
<%
Dim strURL
strURL = &quot;BOM.asp?LineNumber=1&quot;
%>
<A HREF=&quot;<%=strURL%>&quot;>Associated BOM</A>

hth,
JPB
 
Fixed the fact above that I was not passing VarName=Value.

Here is my Anchor tag:

<A HREF=&quot;BOMTest.asp?row=1&quot;>Item 1</A>

Here is corresponding code in BOMTest.adp:

<%
strText = Request.ServerVariables(&quot;row&quot;)
%>
<H1>Parm===><%Response.Write strText%><===</H1></BODY>

Here is the output when I click the link:

Parm===><===

Am I anywhere close on this? Thanks!
 
Thanks, JPB! I must have been correcting my code while you were pointing out the problem.

However, per my post above, when I click the link and BOMTest.asp runs it is not finding the query string I passed into it. What am I doing wrong?

Thanks!
 
On the calling side, append ?row=1 to the link url. On the receiving side, parse ServerVariables likes so:

strTemp = Request.ServerVariables(&quot;QUERY_STRING&quot;)

In the above example strTemp would hold &quot;row=1&quot;.

You might also want to check out Retrieving and Displaying the ServerVariables collection faq333-4559.

Good Luck!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top