Runtime Checkbox value update issue.

  1. #1

    Runtime Checkbox value update issue.

    Following is a sample code, I have been banging my head against. All I want is when I check the Parent Checkbox, Child should be checked as well. Kind of toggel with Parent.
    What I am observing is that the Child Checkbox's value is set correctly, but it is not shown on the web page (it should be same as Parent). Now, if were to just Alt+Tab to another window and Alt+Tab back to the web browser, it automatically shows correct value in Child Checkbox (same as Parent). Have anyone faced this? Am I missing something in code to refresh the checkbox status after assigning the value? Help!

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ExtTest1._Default" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" 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 runat="server">
        <title></title>
        <script type="text/javascript">
            var CB1_Changed = function (e) {
                if (e.checked) {
                    Ext.getCmp("Checkbox2").setValue(true);
                } else {
                    Ext.getCmp("Checkbox2").setValue(false);
                };
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <ext:FormPanel ID="FormPanel1" runat="server" Title="My Test Form" Padding="5"
            Frame="true" LabelWidth="100"  Width="300" 
            Height="200">
            <Items>
                <ext:Checkbox ID="Checkbox1" BoxLabel="Parent" runat="server">
                    <Listeners>
                        <Change Fn="CB1_Changed" />
                    </Listeners>
                </ext:Checkbox>
                <ext:CheckboxGroup ID="CheckboxGroup1" runat="server">
                    <Items>
                        <ext:Checkbox ID="Checkbox2"  BoxLabel="Child" runat="server">
                        </ext:Checkbox>
                    </Items>
                </ext:CheckboxGroup>
            </Items>
        </ext:FormPanel>
        </form>
    </body>
    </html>
  2. #2

    Solved!

    Solution:
    Instead of using Change listener, use Check listener. Check immediatly runs the handler or function upon checking or unchecking. Change will fire only when you leave the checkbox and you will need to render the dynamically updated controls.

               <ext:Checkbox ID="Checkbox1" BoxLabel="Parent" runat="server">
                    <Listeners>
                        <Check Fn="CB1_Changed" />
                    </Listeners>
                </ext:Checkbox>

Similar Threads

  1. [CLOSED] Checkbox value update issue.
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 20, 2011, 11:16 AM
  2. Replies: 4
    Last Post: Feb 21, 2011, 10:02 PM
  3. [CLOSED] Add checkbox to checkboxgroup during runtime
    By dnguyen in forum 1.x Legacy Premium Help
    Replies: 46
    Last Post: Jan 12, 2011, 10:15 PM
  4. Replies: 0
    Last Post: Sep 22, 2010, 10:43 AM
  5. Update css class does not work runtime
    By 78fede78 in forum 1.x Help
    Replies: 2
    Last Post: Jul 21, 2010, 9:47 PM

Tags for this Thread

Posting Permissions