How to Enable/Disable a asp:CheckBox

R

RSB

Hi Everyone,

this is so strange... :blush:((
i have a test.aspx page with two web forms elements, a check box and a
Button. Now i can change the State of the Button from disabled to Enable on
the client's side but not with the Checkbox. What am i doing wrong here..
here is the CODE of my test.aspx page.. so in my JavaScript function
"execthis" i am able to Enable the Button1 but not CheckBox1... Please help
me.. thanks

RSB


<%@ Page Language="vb" AutoEventWireup="false" src="test1.aspx.vb"
Inherits="test1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
title>test1</title>
<script language="javascript">
<!---
function execthis()
{
window.Form1.CheckBox1.disabled = false;
window.Form1.Button1.disabled = false;

}


-->

</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:CheckBox id="CheckBox1" runat="server"
Enabled="False"></asp:CheckBox>
<asp:Button id="Button1" runat="server" Text="Button"
Enabled="False"></asp:Button>
<INPUT type="button" value="Button" onclick='javascript:execthis();'>
</form>
</body>
</HTML>
 
K

Ken Cox [Microsoft MVP]

The problem is that the asp:checkbox control renders a <span
disabled="disabled"> container around the checkbox as a way of enabling
disabling the accompanying text content (if any). The container is getting
in your way.

You need to find a way to dynamically "undisable" the span. Might be easier
to use an HTML control?

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top