将参数传递给经典ASP包含文件

时间:2010-03-31 10:43:25

标签: asp-classic include

我必须使用经典ASP来构建网站。 我希望能够使用包含文件作为页眉和页脚。

如何将变量传递给包含文件,以便我可以影响标题等内容。 以下是我想要做的一些例子:

的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>
    <title><% Response.write title %></title>

3 个答案:

答案 0 :(得分:6)

document.write是客户端JavaScript。你在header.inc中想要的是:

<html>
<head>
    <title><%=title%></title>

或者更详细地说:

<html>
<head>
    <title><% Response.Write title %></title>

除此之外,你所拥有的东西应该有效(没有Server.Execute,只需在你向下展示时进行包含)。

答案 1 :(得分:0)

包含文件在线呈现/解释...我只是在主文件中设置一些值,并在包含文件中检查它们。否?

答案 2 :(得分:-2)

据我所知,使用会话是唯一的方法

<%
Session("title") = "mytitle"

Server.Execute("header.inc")
%>

<title><% response.write(Session("title")) %></title>

article也显示相同的结果

相关问题