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



The information in this article applies to:

  • Microsoft ASP.NET (included with the .NET Framework 1.1)
  • Microsoft ASP.NET (included with the .NET Framework) 1.0
  • Microsoft Active Server Pages

This article was previously published under Q316174

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.

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>
				

STATUS

This behavior is by design.

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.

Modification Type:MinorLast Reviewed:2/11/2004
Keywords:kbprb kbWebForms KB316174 kbAudDeveloper