Link to home
Start Free TrialLog in
Avatar of shahjagat
shahjagatFlag for United States of America

asked on

Jquery/Javascript enable or disable textbox in a radgrid edit template

I have a column with check box named "IsActive" and a column with text box named "Comments".
I have a radgrid with a check box column.
When i uncheck the checkbox in edit mode, i want to enable the text box.
 I have the following code and i get
"The name 'chkActive' does not exist in the current context."
How do i access the checkbox within a radgrid?


 <telerik:RadGrid ID="rgClientInfo" runat="server" AutoGenerateColumns="False">
<telerik:GridTemplateColumn UniqueName="IsActive" HeaderText ="IsActive" >
                                            <EditItemTemplate>
                                            <ASP:CheckBox ID="chkActive" runat="server" CssClass="checkbox" Text="IsActive" onclientclick="ActivateCommentsWhenClientInactive()"  />
                                            </EditItemTemplate>   
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="Comments" HeaderText ="Comments" UniqueName="Comments">
                                            <ItemTemplate>
                                              <ASP:Label ID="lblMemComments" runat="server" Text='<%# Eval("Comments") %>' ToolTip="Member Comments" />
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                            <telerik:RadTextBox runat="server" ID="rtbComments" Text="" Enabled="false" ></telerik:RadTextBox>
                                            </EditItemTemplate>
</telerik:GridTemplateColumn>
</telerik:RadGrid>

 function ActivateCommentsWhenClientInactive()
                 {

//something like this when check box is unchecked, comments should be enabled.
                 if($("#<%=chkActive.ClientID %>").prop('checked', false))
                 {
                 $("#<%=txtComments.ClientID %>").removeattr("disabled");
                 }
                 
                 }

Open in new window

Avatar of shahjagat
shahjagat
Flag of United States of America image

ASKER

I tried the following. it doesn't give any error but does not enable the textbox.

 function ActivateCommentsWhenClientInactive()
                 {
                 $("#<%=RadGrid1.ClientID %> input:checkbox[id*=chkActive]").click(function () {
                  if($("#<%=RadGrid1.ClientID %> input:checkbox[id*=chkActive]").prop('checked', false))
                    {
                        //$("#<%=RadGrid1.ClientID %> input:textbox[id*=rtbComments]").removeattr("disabled");
                        $("#<%=RadGrid1.ClientID %> input:textbox[id*=rtbComments]").prop('enabled', true);
                    }
                  });
                  }

Open in new window

Avatar of Julian Hansen
It would be helpful if we could see the rendered HTML to see what the control looks like as HTML.
Thanks for your reply. We moved in a different direction with the code.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.