473,749 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with CheckListBox

Mau
I have a big problem with the CheckListBox control:
if I disable it and the I enable it I loose
selection (checking) , why?
There is a way to solve this?

Tanks

M

Here some code:

<%@ Page Language="C#" %>
<script runat="server">

void Button1_Click(o bject sender, EventArgs e) {
CheckBoxList1.E nabled= false;
}

void Button2_Click(o bject sender, EventArgs e) {
CheckBoxList1.E nabled= true;
}

void Page_Load(objec t sender, EventArgs e) {
if (!IsPostBack)
{
CheckBoxList1.I tems.Add ("1");
CheckBoxList1.I tems.Add ("2");
CheckBoxList1.I tems.Add ("3");
}
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:CheckBoxLi st id="CheckBoxLis t1"
runat="server"> </asp:CheckBoxLis t>
</p>
<p>
<asp:Button id="Button1" onclick="Button 1_Click" runat="server"
Text="Disable"> </asp:Button>
</p>
<p>
<asp:Button id="Button2" onclick="Button 2_Click" runat="server"
Text="Enable"></asp:Button>
</p>
</form>
</body>
</html>
Nov 18 '05 #1
3 1501
Hi,

It's the browser that doesn't post the values of any disabled controls. The
same happens if you disable a TextBox, RadioButton, etc. It is by design.

http://support.microsoft.com/?kbid=287738

Greetings
Martin
"Mau" <no*@sorry.co m> wrote in message
news:PL******** ************@tw ister1.libero.i t...
I have a big problem with the CheckListBox control:
if I disable it and the I enable it I loose
selection (checking) , why?
There is a way to solve this?

Tanks

M

Here some code:

<%@ Page Language="C#" %>
<script runat="server">

void Button1_Click(o bject sender, EventArgs e) {
CheckBoxList1.E nabled= false;
}

void Button2_Click(o bject sender, EventArgs e) {
CheckBoxList1.E nabled= true;
}

void Page_Load(objec t sender, EventArgs e) {
if (!IsPostBack)
{
CheckBoxList1.I tems.Add ("1");
CheckBoxList1.I tems.Add ("2");
CheckBoxList1.I tems.Add ("3");
}
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:CheckBoxLi st id="CheckBoxLis t1"
runat="server"> </asp:CheckBoxLis t>
</p>
<p>
<asp:Button id="Button1" onclick="Button 1_Click" runat="server" Text="Disable"> </asp:Button>
</p>
<p>
<asp:Button id="Button2" onclick="Button 2_Click" runat="server" Text="Enable"></asp:Button>
</p>
</form>
</body>
</html>

Nov 18 '05 #2
Mau
> It's the browser that doesn't post the values of any disabled controls.
The
same happens if you disable a TextBox, RadioButton, etc. It is by design.


So, there is no solution?
:-(
Nov 18 '05 #3
Hi,

"Mau" <no*@sorry.co m> wrote in message
news:6m******** ************@tw ister2.libero.i t...
It's the browser that doesn't post the values of any disabled controls. The
same happens if you disable a TextBox, RadioButton, etc. It is by

design.
So, there is no solution?
:-(


Did you read the knowlege base article at
http://support.microsoft.com/?kbid=287738 ? There is a resolution for the
problem which involves some client-side scripting. Another approach may be
storing the selected index in the ViewState when you disable the control and
then setting it back when you enable the control.

Greetings
Martin
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2966
by: Bernie Yaeger | last post by:
Is there any way to get a listbox or a checklistbox behave in an autocomplete manner, such that given 'two', 'three', 'water', 'them' would bring the selection to 'two' (not 'water') when I key in 'tw'? I know using various autocomplete routines I can do this with a combobox, but I need to do it with either a listbox or a checklistbox. Thanks for any help. Bernie Yaeger
10
2209
by: Chris Clement | last post by:
I didn't write this code so I'm not sure what is going on with this error. checkedListBox1 is a public object. Why does the error say that it is expecting a 'class' in a for loop? Is it because the method is static? Here is the error and the code: C:\...\Form1.cs(1130): 'APP.mainForm.checkedListBox1' denotes a 'field' where a 'class' was expected public static void MenuItem_Click(object sender, System.EventArgs e)
1
7363
by: comic_rage | last post by:
Hi, I created a checkListBox to allow the user to select and place a check next to multiple items in the GUI. I would like to add a 2 column where the first column show the description of the item and the second column show the version. How can I create 2 columns with a checkListBox? How can I add a header above the 2 columns to show item | version?
2
16676
by: Mike Kim | last post by:
hi all, i have a checklistbox populated with about 50 items from database. and on the same form, i added to button to do the following. if you click this button, i want to have all items in the checklistbox to be checked i want to have all items in the checklistbox to be unchecked. thanks advance, folks.
1
1567
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. This work fine for most cases, allowing the user to resize the form (and controls within the form. The forms them selves are create dynamically when the user drags a node from a listview to a panel (contained in a Usercontrol which is hosted by...
3
1645
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. This work fine for most cases, allowing the user to resize the form (and controls within the form. The forms them selves are create dynamically when the user drags a node from a listview to a panel (contained in a Usercontrol which is hosted by...
0
3118
by: Ville Mattila | last post by:
Dear readers, I've some problems with the data binding of the checklistbox control. I'm using it with user preferences that are stored in a XML File. Information from the file is fetched with SelectSingleNode and XPath. The checklistbox list values and display texts are loaded from a datatable. I've managed to do that with the DataSource, DisplayMember and ValueMember. No problems with that.
0
1141
by: Kevin | last post by:
I purchased an ActiveX control from someone a few years ago. It's a checklistbox. It's works kind of quirky in my VB2005 Windows Forms app. They have a new version of the checklistbox that I just got from them. It was created in May 2005. When I open my program now, it bombs out and just disappears. When I open it again I get the message: "An error was encountered while opening associated documents the last time this solution was loaded....
3
3388
by: khalidjan9 | last post by:
I have data in an arraylist and i want to add data to checklist box on runtime and i also want to display a textbox besides it so that i get the comments example : checklistbox "text" textbox checklistbox "text" textbox checklistbox "text" textbox checklistbox "text" textbox checklistbox "text" textbox can any 1 pleeez help... tks in adv.. :)
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.