This is a migrated thread and some comments may be shown as answers.

RadTextBox disable when click radio button

2 Answers 232 Views
Input
This is a migrated thread and some comments may be shown as answers.
Myo
Top achievements
Rank 1
Myo asked on 07 Apr 2014, 09:52 AM
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 Answers, 1 is accepted

Sort by
0
Krishnaprabhuraja
Top achievements
Rank 1
answered on 08 Apr 2014, 10:03 AM
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
0
Myo
Top achievements
Rank 1
answered on 09 Apr 2014, 01:48 AM
It is working now. Thanks for your help.
Tags
Input
Asked by
Myo
Top achievements
Rank 1
Answers by
Krishnaprabhuraja
Top achievements
Rank 1
Myo
Top achievements
Rank 1
Share this question
or