[CLOSED] Setting Checkbox value to either true or false during runtime does not work

  1. #1

    [CLOSED] Setting Checkbox value to either true or false during runtime does not work

    Hi,

    I'm trying to set the Checkbox value to either true or false during runtime using return values from database in code behind and it doesn't seem to work. By the way, i'm using version 0.8.2.

    Sample server side code
                            char[] seps = { ',', '\n', '\r' };
                            string[] WeekDays = drvSchedule["PATTERN_WEEKLY_WEEKDAYS"].ToString().Split(seps);
    
                            for (int i = 0; i < WeekDays.Length; i++)
                            {
                                foreach (Coolite.Ext.Web.Checkbox cbSelected in cbgWeekly.Items)
                                {
                                    if (cbSelected.BoxLabel == WeekDays[i].Trim())
                                    {
                                        cbSelected.Checked = true;
                                    }
                                }
                            }
    Sample client side code
                                                                                    <ext:CheckboxGroup 
                                                                                        ID="cbgWeekly" 
                                                                                        runat="server" 
                                                                                        HideLabel="true"
                                                                                        ColumnsNumber="4"  
                                                                                        AutoWidth="true">
                                                                                        <Items>
                                                                                            <ext:Checkbox ID="cbSunday" runat="server" BoxLabel="Sunday" />
                                                                                            <ext:Checkbox ID="cbMonday" runat="server" BoxLabel="Monday" />
                                                                                            <ext:Checkbox ID="cbTuesday" runat="server" BoxLabel="Tuesday" />
                                                                                            <ext:Checkbox ID="cbWednesday" runat="server" BoxLabel="Wednesday" />
                                                                                            <ext:Checkbox ID="cbThursday" runat="server" BoxLabel="Thursday" />
                                                                                            <ext:Checkbox ID="cbFriday" runat="server" BoxLabel="Friday" />
                                                                                            <ext:Checkbox ID="cbSaturday" runat="server" BoxLabel="Saturday" />
                                                                                        </Items>
                                                                                    </ext:CheckboxGroup>
    Last edited by Daniil; Feb 24, 2011 at 11:06 AM. Reason: Marked as [CLOSED]. No more information was provided.
  2. #2
    Hi,

    I cannot reproduce it, here is my test case
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <script runat="server">
            protected void Click1(object sender,AjaxEventArgs e)
            {
                foreach (Coolite.Ext.Web.Checkbox cbSelected in cbgWeekly.Items)
                {
                    cbSelected.Checked = true;
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server">
            </ext:ScriptManager>
            
             <ext:CheckboxGroup
                ID="cbgWeekly"
                runat="server"
                HideLabel="true"
                ColumnsNumber="4" 
                AutoWidth="true">
                <Items>
                    <ext:Checkbox ID="cbSunday" runat="server" BoxLabel="Sunday" />
                    <ext:Checkbox ID="cbMonday" runat="server" BoxLabel="Monday" />
                    <ext:Checkbox ID="cbTuesday" runat="server" BoxLabel="Tuesday" />
                    <ext:Checkbox ID="cbWednesday" runat="server" BoxLabel="Wednesday" />
                    <ext:Checkbox ID="cbThursday" runat="server" BoxLabel="Thursday" />
                    <ext:Checkbox ID="cbFriday" runat="server" BoxLabel="Friday" />
                    <ext:Checkbox ID="cbSaturday" runat="server" BoxLabel="Saturday" />
                </Items>
            </ext:CheckboxGroup>
            
            <ext:Button runat="server" Text="Click">        
                <AjaxEvents>
                    <Click OnEvent="Click1" />
                </AjaxEvents>
            </ext:Button>
         
      
        </form>
    </body>
    </html>
  3. #3
    Hi Vladimir,

    Thanks for the quick response. Can the checkbox value (checked) be set to true or false based on the value returned from the database? In short, my scenario is when a popup window is loaded, the checkboxes will be set to either true or false based on the returned values?

    Thanks,
    Daniel
  4. #4
    Just to be clear. Can Checkbox value be set during runtime, not within Ajax Method or Ajax Event Handler?

    Thanks,
    Dan
  5. #5
    Hi,

    Checkbox can be set at any moment. What difference between "runtime" (as you mentioned) and ajax method?

Similar Threads

  1. [CLOSED] Checkbox return true/false
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 04, 2011, 5:42 AM
  2. Replies: 1
    Last Post: May 27, 2011, 11:39 AM
  3. [CLOSED] Disabled Checkbox is always false and shows enabled true.
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 12, 2009, 4:10 AM
  4. Replies: 2
    Last Post: Mar 29, 2009, 3:20 PM
  5. Replies: 3
    Last Post: Jan 29, 2009, 5:32 PM

Posting Permissions