0

I want to include a file in html but I want to pass it a variable using asp (i.e.)

<% Dim s = "file.html %>
<!-- #include file="<% s %>"-->

That doesn't seem to work, is there a way around this to get the above to work?

3 Answers 3

3

IIS server side includes do not support variables.

See the documentation.


One workaround would be to read the file (using FileSystemObject) into a variable and outputting that directly to the page using <%=%>.

Sign up to request clarification or add additional context in comments.

Comments

0

Would something like this work for you?

<% if condition Then %>
<!--#include file="File1.htm"-->
<% elseif condition Then %>
<!--#include file="File2.htm"-->
<% end if %>

Comments

0

What About This ?

<% Server.Execute "" & s & ".html" %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.