Problem with CheckListBox

Discussion in 'ASP .Net' started by Mau, Sep 27, 2004.

  1. Mau

    Mau Guest

    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>
    Mau, Sep 27, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:pLV5d.10763$...
    > 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>
    >
    >
    Martin Dechev, Sep 27, 2004
    #2
    1. Advertising

  3. Mau

    Mau Guest

    > 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?
    :-(
    Mau, Sep 27, 2004
    #3
  4. Hi,

    "Mau" <> wrote in message
    news:6mW5d.11003$...
    > > 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
    Martin Dechev, Sep 27, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D. Shane Fowlkes
    Replies:
    0
    Views:
    557
    D. Shane Fowlkes
    Apr 7, 2004
  2. brian

    CheckListBox

    brian, Apr 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    514
    brian
    Apr 27, 2004
  3. Vikram

    Height of checklistbox

    Vikram, Mar 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,861
    Steve C. Orr [MVP, MCSD]
    Mar 1, 2005
  4. =?Utf-8?B?VmlkZHM=?=

    CheckListBox MouseOver

    =?Utf-8?B?VmlkZHM=?=, Jan 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,667
    cbDevelopment
    Mar 13, 2006
  5. Replies:
    1
    Views:
    1,238
    Ed Leafe
    Jan 13, 2005
Loading...

Share This Page