How to disable a TextField when a CheckBox is changed?

  1. #1

    How to disable a TextField when a CheckBox is changed?

    Hello,

    I'm new to ext.net and ext.js. I have this checkbox of which id is CheckboxTax2 and this textfield of which id is TextFieldReferer2 . How to achieve when I checked or unchecked the checkbox it will disable/enable the textfield. I've tried this code but it doesn't work

                                                                <ext:Checkbox
                                                                    ID="CheckboxTax2"
                                                                    DataIndex="CheckboxTax2"
                                                                    runat="server"
                                                                    FieldLabel="Tax">
                                                                    <Listeners>                                                                                                                                        
                                                                        <Change Handler="#{TextFieldReferer2}.Text = ''; #{TextFieldReferer2}.Disabled = !#{CheckboxTax2}.Checked" />                                                                    
                                                                    </Listeners>
                                                                </ext:Checkbox>
    Is there something wrong with the code? Any advice is welcome. Thank you.
  2. #2
    Hi,

    Welcome to Ext.NET!

    Here is the example.

    Example
    <%@ Page Language="C#" %>
     
    <%@ 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>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:TextField ID="TextField1" runat="server" Text="Some text" />
            <ext:Checkbox runat="server" BoxLabel="Disable">
                <Listeners>
                    <Check Handler="TextField1.setDisabled(checked);" />
                </Listeners>
            </ext:Checkbox>
        </form>
    </body>
    </html>
    See also
    http://docs.sencha.com/ext-js/3-4/#!...ox-event-check
    http://docs.sencha.com/ext-js/3-4/#!...od-setDisabled
  3. #3
    Thank you! great it works!

    so Listeners is actually code to run on the client side, then it uses ext js language. I get it now.

Similar Threads

  1. [CLOSED] TextField.FieldLabel is not changed in Code Behind
    By supera in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 24, 2012, 3:28 PM
  2. Gridpanel Listner handling checkbox changed
    By shijith in forum 1.x Help
    Replies: 0
    Last Post: Aug 04, 2010, 6:05 AM
  3. How to disable and enable a checkbox using Javascript
    By phancongphuoc in forum 1.x Help
    Replies: 1
    Last Post: Mar 24, 2010, 8:00 AM
  4. [1.0] Checkboxselectionmodel hide/disable checkbox
    By SouthDeveloper in forum 1.x Help
    Replies: 1
    Last Post: Mar 22, 2010, 2:19 PM
  5. Checkbox changed handler in code-behind
    By drakaan in forum 1.x Help
    Replies: 6
    Last Post: Aug 24, 2009, 3:07 PM

Tags for this Thread

Posting Permissions