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



The information in this article applies to:

  • Microsoft Active Server Pages
  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Server 5.0

This article was previously published under Q236889

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 that this is a bug in the Microsoft products that are 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), the following error message occurs:
    A Runtime Error has occurred.
    Do you wish to Debug?
    Line: 8
    Error: 'False' is undefined

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbbug kbScript KB236889