Microsoft Knowledge Base Email Alertz

(236889) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 236889 - Last Review: June 24, 2004 - Revision: 4.1

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

This article was previously published under Q236889

On This Page

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

APPLIES TO
  • Microsoft Active Server Pages 4.0
  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Services 5.0
Keywords: 
kbbug kbscript KB236889
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate