BUG: JScript from ASP Page Sends Mixed-Case Boolean Values to Client

ID: Q236889


The information in this article applies to:
  • Active Server Pages
  • Microsoft Internet Information Server versions 4.0, 5.0


SYMPTOMS

Active Server Pages (ASP) script sends Microsoft JScript Boolean values to the client as "True" and "False" instead of "true" and "false". JScript is case-sensitive and expects "true" and "false" for Boolean values, so the values "True" and "False" do not work.


RESOLUTION

A workaround is to create a helper function that converts the "True" and "False" strings to all lowercase before writing them to the browser. Below is a sample:


<%@ LANGUAGE="JScript" %>
<%
var n = "0"; 
var x = "0";
var y = "0";
x = (n == "1");

y = (n == "0");

function convertboolean(boolval)
{
	boolval = boolval.toString().toLowerCase();
	return boolval;
}
%>
<html>
<head></head>
<body>
<P>
Checkbox1 <INPUT id=Checkbox1 type=checkbox><BR>
Checkbox2 <INPUT id=Checkbox2 type=checkbox>
<script language="JScript">
Checkbox1.checked = <%= convertboolean(x)%>;
Checkbox2.checked = <%= convertboolean(y)%>;
</script>
</body> 


STATUS

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


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create an ASP page with the following code:
    
    <%@ LANGUAGE="JScript" %>
    <%
    var n = "0"; 
    var x = "0";
    var y = "0";
    x = (n == "1");
    y = (n == "0");
    %>
    <html>
    <head></head>
    <body>
    <P>
    Checkbox1 <INPUT id=Checkbox1 type=checkbox><BR>
    Checkbox2 <INPUT id=Checkbox2 type=checkbox>
    <script language="JScript">
    Checkbox1.checked = <%= x%>;
    Checkbox2.checked = <%= y%>;
    </script>
    </body>
    </html> 


  2. Save the ASP page to the root directory of the default Web site on an Internet Information Server.


  3. Browse to the page with a Web browser.

    Notice that neither checkbox is selected, although you would expect Checkbox 2 to be selected.

    NOTE: If you are using Internet Explorer 5.0 and have selected Display a notification about every script error on the Advanced tab of the Internet Options window (which is accessed from the Tools menu) you will see the following error:
    Line: 8
    Error: 'False' is undefined


Additional query words:

Keywords : kbASP kbJScript kbScript kbGrpASP kbDSupport kbiis400 kbiis500
Version : winnt:
Platform : winnt
Issue type : kbbug


Last Reviewed: December 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.