Finding asp control in ItemTemplate in RadLightBox Client side

2 posts, 0 answers
  1. Rui
    Rui avatar
    14 posts
    Member since:
    Nov 2012

    Posted 26 Mar 2014 Link to this post

    I am having problem with finding asp controls in the ItemTemplate in RadLightBox.
    I have a RadComboBox and asp checkbox inside the RadLightBox ItemTemplate.
    In my javascript I can find the RadComboBox, but cannot find the checkbox, it's getting null.
    I also tried to find RadButton, it can find it, but how do I check it's checked or not from client side like asp checkbox.
    But I still want to try to use asp checkbox so that css is consistent across our site.
    Here is my code:
     <telerik:RadLightBox height="240" Width="890" ID="LightBox" Font-Size="Medium"  runat="server"   Modal="true" PreserveCurrentItemTemplates="true" style="z-index:99">
                    <ClientSettings >
                        <ClientEvents  OnShowing="findControls" OnClosing="showHTMLScroll"/>
                        <AnimationSettings  HideAnimation="Resize" NextAnimation="Fade" PrevAnimation="Fade"  ShowAnimation="Resize" />
                    <Items >
                                    <div >

                                        <asp:CheckBox  ID="cb1" runat="server" Visible="true"   />
                                        <%--<telerik:RadButton ID="btnToggle" runat="server" ToggleType="CheckBox" ButtonType="LinkButton" >
                                           <telerik:RadButtonToggleState Text="Checked" PrimaryIconCssClass="rbToggleCheckboxChecked" />
                                           <telerik:RadButtonToggleState Text="UnChecked" PrimaryIconCssClass="rbToggleCheckbox" />
                                        <telerik:RadComboBox runat="server" ID="RCB"  Width="300" Height="300" Skin="MetroTouch"
                                              EmptyMessage="-Please Select -" CssClass="right-field" Visible="true" 
                                                    <asp:CustomValidator ID="cvl" runat="server" ValidationGroup="vgroup1" CssClass="error-label" ErrorMessage="Please select a reason"
                                                     ClientValidationFunction="cvlValidate"  />
                                        <span class="left-field left-label">&nbsp;</span>
                                        <asp:Button runat="server" CssClass="action-button" Text="Submit" value="Submit" ID="bnSubmit" CausesValidation="true" onclick="bnSubmitVoice_Click" ValidationGroup="vgroup1"/>


       function findControls() {
           var cb = $find('<%= ((CheckBox)LightBoxReasonVoice.FindControl("cb1")).ClientID %>');;
            var rcb = $find('<%= ((RadComboBox)LightBoxReasonVoice.FindControl("RCB")).ClientID %>');


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Mar 2014 in reply to Rui Link to this post

    Hi Rui,

    As a work around please try the following code snippet to access asp control in client side.

    <asp:CheckBox ID="cb1" runat="server" Visible="true" CssClass="checkstate" />

    var lightbox = $find("<%=LightBox.ClientID %>");
    //asp check box
    var cb = lightbox.get_element().getElementsByClassName("checkstate");

Back to Top