473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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(object sender, EventArgs e) {
CheckBoxList1.Enabled= false;
}

void Button2_Click(object sender, EventArgs e) {
CheckBoxList1.Enabled= true;
}

void Page_Load(object sender, EventArgs e) {
if (!IsPostBack)
{
CheckBoxList1.Items.Add ("1");
CheckBoxList1.Items.Add ("2");
CheckBoxList1.Items.Add ("3");
}
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:CheckBoxList id="CheckBoxList1"
runat="server"></asp:CheckBoxList>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Disable"></asp:Button>
</p>
<p>
<asp:Button id="Button2" onclick="Button2_Click" runat="server"
Text="Enable"></asp:Button>
</p>
</form>
</body>
</html>
Nov 18 '05 #1
3 1478
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.com> wrote in message
news:PL********************@twister1.libero.it...
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(object sender, EventArgs e) {
CheckBoxList1.Enabled= false;
}

void Button2_Click(object sender, EventArgs e) {
CheckBoxList1.Enabled= true;
}

void Page_Load(object sender, EventArgs e) {
if (!IsPostBack)
{
CheckBoxList1.Items.Add ("1");
CheckBoxList1.Items.Add ("2");
CheckBoxList1.Items.Add ("3");
}
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:CheckBoxList id="CheckBoxList1"
runat="server"></asp:CheckBoxList>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Disable"></asp:Button>
</p>
<p>
<asp:Button id="Button2" onclick="Button2_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.com> wrote in message
news:6m********************@twister2.libero.it...
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
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...
10
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...
1
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...
2
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...
1
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. ...
3
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. ...
0
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...
0
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...
3
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.