Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP, Javascript and parsing

Reply
Thread Tools

ASP, Javascript and parsing

 
 
Martin Walke
Guest
Posts: n/a
 
      03-24-2006
Hi all,

Can someone help me out here? I'm been using ASP and VBScript for some years
but have just ventured into the realms of using server side Javascript and
apart from hitting various niggerly problems, this one baffles me.

This is a very simplistic example of the problem.

<%@ Language="JavaScript"%>

<html>
<body>

Here it is
<script language="javascript" runat="server">
Response.Write("in the")
</script>
middle

</body>
</html>

When I run this I get

"Here it is middle in the" rather than "Here it is in the middle".

Can someone tell me why? If I use <%= then it's fine but my main program is
using a javascript server side include which I'm including by using the
<script src ....> as I can't get the <!--#include method to work.

Am I confusing myself totally by messing up what I thought to be VBScript
and Javascript commands? Or is it something to do with the way in which the
page in parsed for server side commands?

TIA
Confused Martin


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      03-24-2006
Martin Walke wrote on 24 mrt 2006 in
microsoft.public.inetserver.asp.general:

> Can someone help me out here? I'm been using ASP and VBScript for some
> years but have just ventured into the realms of using server side
> Javascript and apart from hitting various niggerly problems, this one
> baffles me.
>
> This is a very simplistic example of the problem.
>
> <%@ Language="JavaScript"%>
>
> <html>
> <body>
>
> Here it is
> <script language="javascript" runat="server">
> Response.Write("in the")
> </script>
> middle
>
> </body>
> </html>
>


try:

<%@ Language="JScript"%>
<html>
<body>
Here it is
<%
Response.Write("in the")
%>
middle
</body>
</html>

============================

runat="server" scripts of the other language run first
then the <% %> scripts inline with the html
then the runat="server" scripts of the same language.

If you think long about ik you will come to like it.

A better explanation, with examples:
<http://www.aspfaq.com/show.asp?id=2045>

[It is always a good idea to read the FAQ before asking questions]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      03-24-2006

"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
news:...
> Hi all,
>
> Can someone help me out here? I'm been using ASP and VBScript for some

years
> but have just ventured into the realms of using server side Javascript and
> apart from hitting various niggerly problems, this one baffles me.
>
> This is a very simplistic example of the problem.
>
> <%@ Language="JavaScript"%>
>
> <html>
> <body>
>
> Here it is
> <script language="javascript" runat="server">
> Response.Write("in the")
> </script>
> middle
>
> </body>
> </html>
>
> When I run this I get
>
> "Here it is middle in the" rather than "Here it is in the middle".
>
> Can someone tell me why? If I use <%= then it's fine but my main program

is
> using a javascript server side include which I'm including by using the
> <script src ....> as I can't get the <!--#include method to work.
>
> Am I confusing myself totally by messing up what I thought to be VBScript
> and Javascript commands? Or is it something to do with the way in which

the
> page in parsed for server side commands?
>
> TIA
> Confused Martin
>



First off you can't preform inline response.writes in a <script
runat="server"> tag. It needs to be <% %>

Secondly isn't the real issue here that <!-- #includes aren't working. Why
not?

Thirdly if you change the script tag language to VBScript it appears to run
first before the rest of the document. Then if you change <% language to
VBScript it runs after the rest of the document. If you then change the
script language back to Javascript it runs before the rest of the document.

I won't try to describe here why that so but it does actually make sense.

Anthony.


 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      03-24-2006
Martin Walke wrote:
> [ <script runat=server> -vs- <%%> ]
> Can someone tell me why? If I use <%= then it's fine but my main
> program is using a javascript server side include which I'm including
> by using the <script src ....> as I can't get the <!--#include method
> to work.

http://aspfaq.com/show.asp?id=2045


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


 
Reply With Quote
 
Martin Walke
Guest
Posts: n/a
 
      03-27-2006
Thanks Anthony and Dave,

Your link, Dave, gives the detail behind what Anthony is hinting at. I'd
seen this info before but couldn't nail it down.

Seeing this info gives the inherent reason why the #include was not working.
I have a large number of objects defined in the include file that weren't
being recognised by the rest of the code due to the reasons mentioned in
Dave's link.

You *could* almost use this order parsing to your advantage but could be
messy from a maintenance point of view. Anyway......

Thanks again guys. I'll just need to re-structure my code.

Martin


"Anthony Jones" <> wrote in message
news:%...
>
> "Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
> news:...
>> Hi all,
>>
>> Can someone help me out here? I'm been using ASP and VBScript for some

> years
>> but have just ventured into the realms of using server side Javascript
>> and
>> apart from hitting various niggerly problems, this one baffles me.
>>
>> This is a very simplistic example of the problem.
>>
>> <%@ Language="JavaScript"%>
>>
>> <html>
>> <body>
>>
>> Here it is
>> <script language="javascript" runat="server">
>> Response.Write("in the")
>> </script>
>> middle
>>
>> </body>
>> </html>
>>
>> When I run this I get
>>
>> "Here it is middle in the" rather than "Here it is in the middle".
>>
>> Can someone tell me why? If I use <%= then it's fine but my main program

> is
>> using a javascript server side include which I'm including by using the
>> <script src ....> as I can't get the <!--#include method to work.
>>
>> Am I confusing myself totally by messing up what I thought to be VBScript
>> and Javascript commands? Or is it something to do with the way in which

> the
>> page in parsed for server side commands?
>>
>> TIA
>> Confused Martin
>>

>
>
> First off you can't preform inline response.writes in a <script
> runat="server"> tag. It needs to be <% %>
>
> Secondly isn't the real issue here that <!-- #includes aren't working.
> Why
> not?
>
> Thirdly if you change the script tag language to VBScript it appears to
> run
> first before the rest of the document. Then if you change <% language to
> VBScript it runs after the rest of the document. If you then change the
> script language back to Javascript it runs before the rest of the
> document.
>
> I won't try to describe here why that so but it does actually make sense.
>
> Anthony.
>
>




 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      03-27-2006
Martin Walke wrote:
> Thanks Anthony and Dave,
>
> Your link, Dave, gives the detail behind what Anthony is hinting at.
> I'd seen this info before but couldn't nail it down.
>
> Seeing this info gives the inherent reason why the #include was not
> working. I have a large number of objects defined in the include file
> that weren't being recognised by the rest of the code due to the
> reasons mentioned in Dave's link.
>
> You *could* almost use this order parsing to your advantage but could
> be messy from a maintenance point of view. Anyway......
>
> Thanks again guys. I'll just need to re-structure my code.


The situation may not be as dire as you think. My strong recommendation for
using <script runat=server> is to encapsulate everything in functions. If
you do so, you can call those functions from anywhere in the execution order
(even if the called function is in the last order group). I have no idea how
that plays with #include directives, but you could always try it and let us
know.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What libraries should I use for MIME parsing, XML parsing, and MySQL ? John Levine Ruby 0 02-02-2012 11:15 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 09:01 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 08:58 PM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM
Perl expression for parsing CSV (ignoring parsing commas when in double quotes) GIMME Perl 2 02-11-2004 05:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57