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!

passing parameter to #INCLUDE FILE 1

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
I have several ASPs with the following line

<!--#include file="header_allocedit.asp" -->

The header_allocedit.asp page needs to know which page called it. In the header_allocedit.asp page I have the following

<%
dim purpose
purpose = C4
If request.querystring("purp") <> "" Then
purpose = request.querystring("purp")
End if
%>

What do I need in the calling page to make this work? Or does it have to be done differently?
 
Figured it out. (Actually it wasn't that quick; I was tearing my hair out most of yesterday on this.

In header_allocedit.asp, i have a table with anchors such as this for column headers.

<a href="edit_allocC4.asp?site=<%= Request.QueryString("site") %>">C4</a>

which call one of the pages with the header file as the #INCLUDE FILE.

By adding the parameter to the anchor, the request.querystring can look back to the origin. I thought it could only look at the page calling it. so the result is

<a href="edit_allocC4.asp?site=<%= Request.QueryString("site") %>&purp=C4">C4</a>.
 
Technically, an include file literally runs the code that is in the file like it was in the page itself. There is no "call". You can put this in your include file:

Code:
<%
Thispage = Request.ServerVariables("script_name")
%>

I tested to make sure it works, it does return the current URL in which the include file is included in.

[monkey][snake] <.
 
Thanks. I used yours because mine didn't handle one condition while yours covered all conditions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top