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

Finding asp control in ItemTemplate in RadLightBox Client side

1 Answer 102 Views
LightBox
This is a migrated thread and some comments may be shown as answers.
Rui
Top achievements
Rank 1
Rui asked on 26 Mar 2014, 05:28 PM
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");

    }





1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2014, 05:22 AM
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.
Tags
LightBox
Asked by
Rui
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or