Hello,
I am trying to get the reference to a RadButton object (which is used as a check box) which is inside the EditTemplate of a FormView. More specifically, I have the following code:
Then I have the following javascript code:
However, when I looked into the generated HTML code, I saw that the ClientID for the checkbox was the following:
ctl00_ContentPlaceHolder1_EmployerFormView_rdBtnLegal_input
with the problem being _input since the javascript line is rendered to the following:
As a result checkbox is undefined. Btw, there is also a ctl00_ContentPlaceHolder1_EmployerFormView_rdBtnLegal_ClientState
I do not understand why, and I don't know how to get the reference I want. It works fine with the RadTextBox (i.e. there is no _input appended at the end of the ClientID).
Thanks
Lefteris
I am trying to get the reference to a RadButton object (which is used as a check box) which is inside the EditTemplate of a FormView. More specifically, I have the following code:
<telerik:RadFormDecorator id="FormDecorator1" runat="server" DecoratedControls="All" Skin="Metro"></telerik:RadFormDecorator> <asp:Panel runat="server" ID="Panel1"> <asp:FormView ID="EmployerFormView" DataSourceID="EmployerObjectDataSource" DataKeyNames="id" runat="server" DefaultMode="Edit"> <EditItemTemplate> <table> <tr> <td class="auto-style5"> <telerik:RadButton ID="rdBtnPhysical" runat="server" AutoPostBack="False" GroupName="rdEmplrType" Text="Individual" ToggleType="Radio" OnClientCheckedChanged="rdBtnPhysical_CheckedChanged" UseSubmitBehavior="False"> <ToggleStates> <telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadioChecked" /> <telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadio" /> </ToggleStates> </telerik:RadButton> </td> <td> <telerik:RadButton ID="rdBtnLegal" runat="server" AutoPostBack="False" GroupName="rdEmplrType" Text="Legal Entity" ToggleType="Radio" OnClientCheckedChanged="rdBtnLegal_CheckedChanged" UseSubmitBehavior="False"> <ToggleStates> <telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadioChecked" /> <telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadio" /> </ToggleStates> </telerik:RadButton> </td> </tr> <tr> <td class="auto-style5" style="white-space: nowrap"> <label>Employer Registration number:</label> </td> <td style="width: 100px"> <telerik:RadTextBox ID="txtAme" runat="server" EmptyMessage="A.M.E."> </telerik:RadTextBox> </td> </tr>
...
Then I have the following javascript code:
<telerik:RadCodeBlock ID="RadCodeBlock2" runat="server"> <script type="text/javascript"> $(document).ready(function () { var firstName = $('input[id$="txtFirstName"]'); //This works fine firstName = $telerik.toTextBox(firstName); var fathersName = document.getElementById('<%=EmployerFormView.FindControl("txtFathersName").ClientID%>'); //This also works fine fathersName = $telerik.toTextBox(fathersName); var lbl = $get("lblEmplrName"); //The next line returns null reference var checkbox = document.getElementById('<%=EmployerFormView.FindControl("rdBtnLegal").ClientID%>'); //This comes up with an exception since the object is null checkBox = $telerik.toButton(checkBox); if (checkBox.get_checked()) {However, when I looked into the generated HTML code, I saw that the ClientID for the checkbox was the following:
ctl00_ContentPlaceHolder1_EmployerFormView_rdBtnLegal_input
with the problem being _input since the javascript line is rendered to the following:
var checkbox = document.getElementById('ctl00_ContentPlaceHolder1_EmployerFormView_rdBtnLegal');As a result checkbox is undefined. Btw, there is also a ctl00_ContentPlaceHolder1_EmployerFormView_rdBtnLegal_ClientState
I do not understand why, and I don't know how to get the reference I want. It works fine with the RadTextBox (i.e. there is no _input appended at the end of the ClientID).
Thanks
Lefteris