Help and Support

PRB: Server Scripts Within Client Scripts Are Not Colored Correctly

Article ID:191041
Last Review:March 7, 2005
Revision:1.1
This article was previously published under Q191041
On This Page

SYMPTOMS

When a server-side script block appears within a client-side script block, the text of the server-side script block is not colored correctly.

Back to the top

CAUSE

This is caused by a limitation of the editor's parsing engine.

Back to the top

RESOLUTION

There is no workaround. When possible, do not compose server-side script within client-side script.

Back to the top

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Back to the top

MORE INFORMATION

This issue does not affect the run-time nature of any code.

This behavior is produced when server-side code (code within the Active Server Pages [ASP] delimeters <%...%> or script tags with the RUNAT=Server directive) appears within a client-side script block. For example, the following samples will exhibit this behavior:
    <script> myClientVar = <%= myServerVar %> </script><BR/>
    <script> <script runat=server> 'server code </script> </script>
				
This issue may cause further confusion when the language of the server-side script block differs from that of the client-side script block. Consider this script block, where the client-side script is in JavaScript, and the server-side script is the default, VBScript:
   <script language=javascript>

        <% if myExpr then %>
        //do something
        <% end if %>

   </script>
				
In this example, the two "if" keywords are colored blue, but the "then" and "end" keywords are not. This is because the parsing engine interprets the code as a single, client-side script block written in JavaScript. In JavaScript, "then" and "end" are not keywords, and hence are not colored blue.

Confusion in this case can be minimized by capitalizing all keywords when composing VBScript (this is the usual convention). Keywords are case sensitive in JavaScript, so the parsing engine will not color "If" blue as a keyword.

Back to the top

Steps to Reproduce Behavior

In Source view, type this text in an ASP page:
   <script> myClientVar = <%= myServerVar %> </script>
				
The <% and %> script delimiters do not have a yellow background.

Back to the top


APPLIES TO
Microsoft Visual InterDev 6.0 Standard Edition

Back to the top

Keywords: 
kbscript kbide kbprb KB191041

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.