Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: The </SCRIPT> Tag Is Treated As a Closing Tag When Inside a Quoted String


View products that this article applies to.

Symptoms

When you use a </SCRIPT> Hypertext Markup Language (HTML) tag inside a quoted string, the tag is treated as a closing tag rather than as a portion of the string.

↑ Back to the top


Resolution

To work around this behavior, do not directly use the </SCRIPT> tag inside a script section. Instead, you can use alternatives such as the following tag:
chr(60) & "/SCRIPT>
				

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

Steps to Reproduce the Behavior

  1. Copy the following code to a Script.aspx page, and then save it to your Web server:
    <script language="vb" runat="server" id="Script1">
        Private Sub scripTest(ByVal sender As System.Object, ByVal e As System.EventArgs)
    
    	Dim myStr as String
    				
    	myStr = "</script>"
    
        End Sub
    </script>
    
    <HTML>
    	<HEAD>
    		<title>WebForm1</title>
    	</HEAD>
    	<body>
    		<form id="Form1" method="post" runat="server">
    			<asp:Button OnClick="scripTest" id="Button1" style="Z-INDEX: 101; LEFT: 232px; POSITION: absolute; TOP: 62px" runat="server" Text="Button" Width="273px" Height="94px"></asp:Button>
    		</form>
    	</body>
    </HTML>
    
    					
  2. Reference the test page in your Web browser, and the following error message appears:
    Compiler Error Message:BC30648: String constants must end with a double quote
  3. Modify the Script.aspx page, and then change the following line of code from:
    myStr = "</script>"
    					
    to:
    myStr = chr(60) & "/script>"
    					
    Note that the Script.aspx page functions as expected when you change the code.

↑ Back to the top


Keywords: KB316174, kbwebforms, kbprb

↑ Back to the top

Article Info
Article ID : 316174
Revision : 8
Created on : 2/11/2004
Published on : 2/11/2004
Exists online : False
Views : 495