RadTextBox disable when click radio button

3 posts, 0 answers
  1. Myo
    Myo avatar
    24 posts
    Member since:
    Nov 2013

    Posted 07 Apr 2014 Link to this post

    Hi,

    Anybody can help me how to disable radtextbox that (ShowButton="true") when click RadioButton? Even though I set radtextbox to disable on client site and textbox is disable,but button is still showing.
    I will publish my code for reference.

    .aspx
    (
    <table>
     <tr>
                <td>
                    <asp:RadioButton ID="radGuest" Checked="true" runat="server" GroupName="t" Text="Guest" />
                </td>
                <td colspan="4">
                    <telerik:RadTextBox ShowButton="true" ID="txtGuest" Text="" runat="server" Width="250px">
                        <ClientEvents OnButtonClick="OnGuestClick" />
                    </telerik:RadTextBox>
                    <asp:HiddenField ID="hdnGuestKey" Value = "" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:RadioButton ID="radCompany" runat="server" GroupName="t" Text="Company" />
                </td>
                <td colspan="4">
                    <telerik:RadTextBox ShowButton="true" ID="txtCompany" Text="" runat="server"  Width="250px">
                        <ClientEvents OnButtonClick="OnCompanyClick" />
                    </telerik:RadTextBox>
                    <asp:HiddenField ID="hdnCompany" Value = "" runat="server" />
                </td>
            </tr>
    </table>
    )

    Client Site
    (
       $telerik.$(function () {

                $telerik.$('#<%=radGuest.ClientID %>').unbind('change').bind('change', function () {            
                    var txtGuest = $find('<%=txtGuest.ClientID %>');
                    var txtCompany = $find('<%=txtCompany.ClientID %>');
                    txtGuest.enable();
                    txtCompany.disable();
                   
                });
                $telerik.$('#<%=radCompany.ClientID %>').unbind('change').bind('change', function () {
                    var txtGuest = $find('<%=txtGuest.ClientID %>');
                    var txtCompany = $find('<%=txtCompany.ClientID %>');
                    txtGuest.disable();
                     txtCompany.enable();
               
                });
            });
    )
  2. Krsnaraja
    Krsnaraja avatar
    9 posts
    Member since:
    Aug 2007

    Posted 08 Apr 2014 in reply to Myo Link to this post

    Hi,

    You can try hide/unhide button as a quick fix.

    var $ = jQuery;
     
        $(function () {
            $('#<%=radGuest.ClientID %>').unbind('change').bind('change', function () {           
                enableRadTextBox('<%=txtGuest.ClientID %>', true);
                enableRadTextBox('<%=txtCompany.ClientID %>', false);  
            });
            $('#<%=radCompany.ClientID %>').unbind('change').bind('change', function () {
                enableRadTextBox('<%=txtGuest.ClientID %>', false);
                enableRadTextBox('<%=txtCompany.ClientID %>', true);
            });
        });
     
        function enableRadTextBox(radTextBoxClientId, enable) {
            var $txt = $find(radTextBoxClientId);
            var $txtBtn = $('.riButton', $txt.get_wrapperElement());
     
            if (enable) {
                $txt.enable();
                $txtBtn.show(); // show button
            } else {
                $txt.disable();
                $txtBtn.hide(); //  hide button
            }
        }


    Thanks,
    Krishna Raja
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Myo
    Myo avatar
    24 posts
    Member since:
    Nov 2013

    Posted 08 Apr 2014 in reply to Krsnaraja Link to this post

    It is working now. Thanks for your help.
Back to Top