checkbox not changing value when changed via JS

2 posts, 0 answers
  1. Jason Potter
    Jason Potter avatar
    10 posts
    Member since:
    Sep 2006

    Posted 30 Oct 2013 Link to this post

    Hi there,

    I have created a onclick event for the checkbox's label (since it does not toggle when you click on it), The Javascript is working and is successfully toggling the checkbox when the label clicked, but when I do a postback to save the values it saves the checkboxes as if I have not touched them. If toggle the checkboxes byclicking on the boxes themselves it works but not when not when I toggle then with JS (even if visually they have toggled). 

    Anyone know why?

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Nov 2013 Link to this post

    Hi Jason Potter,

    Please have a look into the sample code I tried which works fine as expected.

    <telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" AutoPostBack="true"
        OnPreRender="RadListBox1_PreRender" OnClientItemChecked="OnClientItemChecked1">
            <telerik:RadListBoxItem Text="Item1" runat="server" Value="1" />
            <telerik:RadListBoxItem Text="Item2" runat="server" Value="2" />
            <telerik:RadListBoxItem Text="Item3" runat="server" Value="3" />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Save" OnClick="RadButton1_Click">

    <script type="text/javascript">
        function CellClick(text, value) {
            var list = $find("<%=RadListBox1.ClientID %>");
        function OnClientItemChecked1(sender, args) {

    protected void RadListBox1_PreRender(object sender, EventArgs e)
        foreach (RadListBoxItem item in RadListBox1.Items)
            item.Attributes.Add("onclick", "CellClick('" + item.Text + "','" + item.Value + "');");
    protected void RadButton1_Click(object sender, EventArgs e)
        string[] data = new string[10];
        for (int i = 0, j = 0; i < RadListBox1.Items.Count; i++)
            if (RadListBox1.Items[i].Checked == true)
                data[i] = RadListBox1.Items[i].Text;
        for (int i = 0; i < data.Length; i++)


Back to Top