[CLOSED] Get Checked items of checkbox group

  1. #1

    [CLOSED] Get Checked items of checkbox group

    Hi Team,

    We are working on checking checkbox group items from code behind and suspending its events, we are doing that by calling javascript function.
    It is working fine up to checking. But when we are trying to get the checked items in another event the checkbox group is returning zero as count

    We summarized the code to reproduce the issue. But actual scenario is while loading usercontrol we are doing checking. And in another button event we are trying to get the checked items.
    How can we achive this functionality?

    Here is the code to reproduce the issue

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CheckGroup.aspx.cs" Inherits="Ext2._2Practice.CheckGroup" %>
    
    
    <%@ Register Namespace="Ext.Net" Assembly="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            var SetCheckBoxCheckValues = function (radio, isChecked) {
                if (radio) {
                    radio.suspendEvents(false);
                    radio.setValue(isChecked);
                    radio.resumeEvents();
                }
            };
        </script>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
    
    
            }
            protected void btnSet_OnEvent(object sender, DirectEventArgs e)
            {
                ResourceManager1.AddScript("SetCheckBoxCheckValues(" + chkSunday.ClientID + "," + true.ToString().ToLower() + ");");
            }
            protected void btnGet_OnEvent(object sender, DirectEventArgs e)
            {
                List<string> lstSelectedDays = new List<string>();
    
    
                chkGroupWeekDaysOption.CheckedItems.ForEach(delegate(Checkbox checkbox)
                {
                    lstSelectedDays.Add(checkbox.BoxLabel);
                });
                int count = lstSelectedDays.Count;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:FieldContainer ID="fcWeekDaysOptions" Padding="50" runat="server" LabelWidth="120" LabelAlign="Left" FieldLabel="Occurence Days">
                <Items>
                    <ext:CheckboxGroup Width="350" ID="chkGroupWeekDaysOption" runat="server"
                        ColumnsNumber="4">
                        <Items>
                            <ext:Checkbox ID="chkSunday" runat="server" BoxLabel="Sunday" />
                            <ext:Checkbox ID="chkMonday" runat="server" BoxLabel="Monday" />
                            <ext:Checkbox ID="chkTuesday" runat="server" BoxLabel="Tuesday" />
                            <ext:Checkbox ID="chkWednesday" runat="server" BoxLabel="Wednesday" />
                            <ext:Checkbox ID="chkThursday" runat="server" BoxLabel="Thursday" />
                            <ext:Checkbox ID="chkFriday" runat="server" BoxLabel="Friday" />
                            <ext:Checkbox ID="chkSaturday" runat="server" BoxLabel="Saturday" />
                        </Items>
                    </ext:CheckboxGroup>
                </Items>
            </ext:FieldContainer>
            <ext:FieldContainer ID="FieldContainer1" Padding="50" runat="server" LabelWidth="120" LabelAlign="Left" FieldLabel="Occurence Days">
                <Items>
                    <ext:Button ID="btnSet" runat="server" StyleSpec="margin-right:50px;" Text="Set">
                        <DirectEvents>
                            <Click OnEvent="btnSet_OnEvent"></Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btnGet" runat="server" Text="Get">
                        <DirectEvents>
                            <Click OnEvent="btnGet_OnEvent"></Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:FieldContainer>
        </form>
    </body>
    </html>
    Please contact if you need more information
    Last edited by Daniil; Oct 25, 2013 at 4:11 PM. Reason: [CLOSED]
  2. #2
    Hi @mohan.bizbites,

    Please call
    radio.syncHiddenState();
    after the setValue call.

Similar Threads

  1. treepanel how does checked only one checkbox
    By btbtbtbbt in forum 2.x Help
    Replies: 0
    Last Post: Sep 13, 2012, 4:08 AM
  2. [CLOSED] CheckBox.Checked is not getting set
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 01, 2011, 12:27 PM
  3. Replies: 1
    Last Post: Feb 15, 2011, 6:45 PM
  4. [CLOSED] [1.0] Dynamically load checkbox in Checkbox Group
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 14, 2010, 6:05 PM
  5. [CLOSED] Adding Checkbox items to checkbox group during a postback?
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 19
    Last Post: Feb 05, 2010, 11:13 AM

Tags for this Thread

Posting Permissions