Include file with param

T

TNG

Hi,

I try to accomplish something like this:

<!--#include file="menu_<%response.write (strproduct)%>.html"-->

But unfortunally, I quess there is something with my syntax... any idea ?
 
A

Adrienne

Hi,

I try to accomplish something like this:

<!--#include file="menu_<%response.write (strproduct)%>.html"-->

But unfortunally, I quess there is something with my syntax... any idea
?

The include is processed before ASP code is processed, and therefore does
not have access to any variables.

What you might want to do is something like:

<% select case request.querystring("page")
case "apples"%>
<!--#include file="menu_apples.html"-->
<% case "oranges"%>
<!--#include file="menu_oranges.html"-->
<% case else%>
<!--#include file="menu_default.html"-->
<% end select%>
 
R

Roland Hall

in message
: I try to accomplish something like this:
:
: <!--#include file="menu_<%response.write (strproduct)%>.html"-->
:
: But unfortunally, I quess there is something with my syntax... any idea ?

The include file executes for the ASP processor. The only way I know to use
an include file dynamically is to use server.execute.

I have an example:

Run this alone and it will report it's virtual path:
http://kiddanger.com/lab/serverdotexec.asp

Run it with ?q=a, ?q=b or ?q=c and it will also include the appropriate
file.

Here's the code:
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True

dim q
q =
server.HTMLEncode(replace(replace(replace(Request.QueryString("q"),"'","''"),";",""),"--",""))

Response.Write Request.ServerVariables("SCRIPT_NAME") & "<br />" & vbCrLf

if q <> "" Then
select case q
case "a"
server.execute "/lab/serverdotexeca.asp"
case "b"
server.execute "/lab/serverdotexecb.asp"
case "c"
server.execute "/lab/serverdotexecc.asp"
case else
Response.Write "Nice try!"
Response.End
end select
end if
%>

This is serverdotexeca.asp. b and c are similar.

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
Response.Write "This is serverdotexeca.asp<br />" & vbCrLf
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
T

TNG

Thx
Adrienne said:
The include is processed before ASP code is processed, and therefore does
not have access to any variables.

What you might want to do is something like:

<% select case request.querystring("page")
case "apples"%>
<!--#include file="menu_apples.html"-->
<% case "oranges"%>
<!--#include file="menu_oranges.html"-->
<% case else%>
<!--#include file="menu_default.html"-->
<% end select%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top