Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Include file with param

Reply
Thread Tools

Include file with param

 
 
TNG
Guest
Posts: n/a
 
      06-09-2005
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 ?


 
Reply With Quote
 
 
 
 
Adrienne
Guest
Posts: n/a
 
      06-09-2005
Gazing into my crystal ball I observed "TNG" <(E-Mail Removed)> writing in
news:SUQpe.114741$(E-Mail Removed)-ops.be:

> 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%>

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
 
Reply With Quote
 
 
 
 
Roland Hall
Guest
Posts: n/a
 
      06-09-2005
"TNG" wrote in message
news:SUQpe.114741$(E-Mail Removed)-ops.be...
: 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


 
Reply With Quote
 
TNG
Guest
Posts: n/a
 
      06-09-2005
Thx
"Adrienne" <(E-Mail Removed)> wrote in message
news:Xns966FEE71D3275arbpenyahoocom@207.115.63.158 ...
> Gazing into my crystal ball I observed "TNG" <(E-Mail Removed)> writing in
> news:SUQpe.114741$(E-Mail Removed)-ops.be:
>
>> 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%>
>
> --
> Adrienne Boswell
> http://www.cavalcade-of-coding.info
> Please respond to the group so others can share



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML::Template->param() : You gave me an odd number of parameters to param()! Dave Perl Misc 5 04-26-2011 02:44 AM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
jsp include and jsp param Robert Mark Bram Java 2 09-12-2005 04:25 AM
Overload by deriv class param; call w base class param ectoplasm C++ 12 07-28-2005 08:20 AM
XSLT: How to replace param name with this param's value ? Geathaa XML 2 07-30-2003 06:48 AM



Advertisments