Passing parameters to classic ASP include files
I have to use classic ASP to build a website. I want to be able to use include files for the header and footer.
How do I pass variables to the include files so that I can affect such things as titles etc. Here is some examples of what I want to do:
index.asp
<%
dim title
title="TITLE"
'Server.Execute("header.inc") <--- Note I tried this but it didnt work also
%>
<!--#include file="header.inc" -->
header.inc
<html>
<head>
<ti开发者_Python百科tle><% Response.write title %></title>
document.write
is client-side JavaScript. What you want in header.inc is:
<html>
<head>
<title><%=title%></title>
Or more verbosely:
<html>
<head>
<title><% Response.Write title %></title>
Other than that, what you have should work (without the Server.Execute
, just do the include as you show further down).
An include file is rendered/interpreted in-line... I would just set some values in the main file, and check for them in the include file. No?
As far as I can tell using sessions is the only way
<%
Session("title") = "mytitle"
Server.Execute("header.inc")
%>
<title><% response.write(Session("title")) %></title>
This article also shows the same results
精彩评论