简体   繁体   English

Server.Execute不执行经典ASP中的代码

[英]Server.Execute not executing code in classic ASP

I'm trying to make use of constants declared in one ASP file in another file. 我试图利用在另一个文件中的一个ASP文件中声明的常量。 Here's a basic code overview of what I am trying to accomplish: 这是我要完成的工作的基本代码概述:

FileA.asp FileA.asp

Const tr__first_name = "First Name"
Const tr__last_name  = "Last Name"
Const tr__english    = "English"

FileB.asp FileB.asp

Server.Execute "FileA.asp"
Response.Write Eval("tr__first_name")

What should happen is that when I run FileB.asp it should print out "First Name" for the Response.Write statement. 应该发生的是,当我运行FileB.asp时,它应该为Response.Write语句打印出“名字”。 If I declare const tr__first_name in FileB.asp resulting in the following code... 如果我在FileB.asp中声明const tr__first_name导致以下代码...

Server.Execute "FileA.asp"
Const tr__first_name = "First Name"
Response.Write Eval("tr__first_name")

Then FileB.asp will print out "First Name" as expected. 然后FileB.asp将按预期方式打印出“名字”。 Any thoughts as to why my first approach won't work? 关于为什么我的第一种方法行不通的任何想法?

The issue is that Server.Execute only runs FileA.asp as a standalone page within FileB.asp. 问题是Server.Execute仅将FileA.asp作为FileB.asp中的独立页面运行。 In other words, it's not like a programming language making a function call--it is simply running the separate page outside the context of the first page, but displaying the results of the separate page inside the first page. 换句话说,这不像是编程语言进行函数调用,它只是在第一页上下文之外运行单独的页面,而是在第一页内部显示单独页面的结果。

Do this instead: 改为这样做:

<!-- #include file="FileA.asp" -->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM