ASP 3.0, SCRIPT SRC include variable scoping 
Author Message
 ASP 3.0, SCRIPT SRC include variable scoping

Hi,

I've had no luck figuring out what happens to the scope of variables
declared in a script block included using the following HTML code:

//the jscript code preceeding
%>
<SCRIPT language="JScript" SRC="myjsinclude.asp"
RUNAT="server"></SCRIPT>
<%
//the jscript code following

I have never been able to reference variables declared in the
"external" script in the code that would follow.  IS there some trick
I'm missing here?  Should the file included in this manner not have
the ".asp" extension?  This addition to ASP was touted as a way to
remove the need for server parsed pages (i.e. server-side includes),
but I've never been able to use it.

Thanks in advance,
Robert



Fri, 25 Jul 2003 05:46:17 GMT  
 ASP 3.0, SCRIPT SRC include variable scoping
The "order of execution" in an ASP page is

1) non-default language RUNAT=SERVER blocks.

2) default language inline script (that is, code within in <%...%> blocks).

3) default language RUNAT=SERVER blocks.

Since the default language in you page appears to be JScript, the

<SCRIPT language="JScript" SRC="myjsinclude.asp" RUNAT="server">
</SCRIPT>

hasn't been parsed/compiled when the <%...//jscript here...%> inline blocks are executed.

So you're caught in a sticky little "catch 22"...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Hi,

> I've had no luck figuring out what happens to the scope of variables
> declared in a script block included using the following HTML code:

> //the jscript code preceeding
> %>
> <SCRIPT language="JScript" SRC="myjsinclude.asp"
> RUNAT="server"></SCRIPT>
> <%
> //the jscript code following

> I have never been able to reference variables declared in the
> "external" script in the code that would follow.  IS there some trick
> I'm missing here?  Should the file included in this manner not have
> the ".asp" extension?  This addition to ASP was touted as a way to
> remove the need for server parsed pages (i.e. server-side includes),
> but I've never been able to use it.

> Thanks in advance,
> Robert



Fri, 25 Jul 2003 09:32:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. script component: include src file

2. Variable confusion - Scoping problem

3. server.execute and variable scoping

4. IFrame - can't script src change in asp app

5. ASP Includes, Constants, and Variables

6. ASP VBscript - including " and % in variable contents

7. ASP 2.0 vs. ASP 3.0

8. iframe src variable

9. Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src

10. how to pass parameters in an include file which is included in an asp page

11. Including External ASP scripts

12. INCLUDE-ing HTML in ASP Scripts

 

 
Powered by phpBB® Forum Software