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

    Hi 
    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:
    aspx:
     <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" />
                    </ClientSettings>
                    <Items >
                        <telerik:RadLightBoxItem>
                            <ItemTemplate>
                                <div>
                                    <div >

                                        <asp:CheckBox  ID="cb1" runat="server" Visible="true"   />
                                        <%--<telerik:RadButton ID="btnToggle" runat="server" ToggleType="CheckBox" ButtonType="LinkButton" >
                                         <ToggleStates>
                                           <telerik:RadButtonToggleState Text="Checked" PrimaryIconCssClass="rbToggleCheckboxChecked" />
                                           <telerik:RadButtonToggleState Text="UnChecked" PrimaryIconCssClass="rbToggleCheckbox" />
                                         </ToggleStates>
                                        </telerik:RadButton>--%>
                                     </div>
                                    <div>
                                        <telerik:RadComboBox runat="server" ID="RCB"  Width="300" Height="300" Skin="MetroTouch"
                                              EmptyMessage="-Please Select -" CssClass="right-field" Visible="true" 
                                              >
                                        </telerik:RadComboBox>
                                               <span>&nbsp;
                                                    <asp:CustomValidator ID="cvl" runat="server" ValidationGroup="vgroup1" CssClass="error-label" ErrorMessage="Please select a reason"
                                                     ClientValidationFunction="cvlValidate"  />
                                               </span>
                                    </div>
                                    <div>
                                        <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"/>
                                    </div>
                                </div>
                            </ItemTemplate>
                        </telerik:RadLightBoxItem>
                    </Items>
             </telerik:RadLightBox>






    javascript:


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

        }





  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.

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

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

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top