tags:

views:

19

answers:

1

I'm trying to make use of constants declared in one ASP file in another file. Here's a basic code overview of what I am trying to accomplish..

FileA.asp

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

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. If I declare const tr__first_name in FileB.asp resulting in the following code...

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. Any thoughts as to why my first approach won't work?

+2  A: 

The issue is that Server.Execute only runs FileA.asp as a standalone page within 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" -->
Russ
Right! See I knew that but for some reason that answer wasn't coming to mind. Thanks.
Rob Segal