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

find control within itemtemplate client side

4 Answers 283 Views
LightBox
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 06 Jan 2014, 02:46 PM
Is there a method for the client side so that I can access the control within the itemtemplate in lightbox item?  I have asp label (or I can use radtextbox) inside of the lightbox itemtemplate and need to change value.

Thank you!

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jan 2014, 05:08 AM
Hi Frank,

Please have a look into the following code snippet to access the ItemTemplate control of RadLightBox from client side.

ASPX:
<telerik:RadLightBox ID="CodeLightBox" runat="server" Width="1000px" Modal="true"
    Height="200px">
    <ClientSettings>
        <AnimationSettings HideAnimation="Resize" NextAnimation="Fade" PrevAnimation="Fade"
            ShowAnimation="Resize" />
    </ClientSettings>
    <Items>
        <telerik:RadLightBoxItem>
            <ItemTemplate>
                <telerik:RadTextBox ID="RadTextBox1" runat="server" CssClass="demo">
                </telerik:RadTextBox>
            </ItemTemplate>
        </telerik:RadLightBoxItem>
    </Items>
</telerik:RadLightBox>

JavaScript:
<script type="text/javascript">
    function OpenCodeLightBox() {
        var lightBox = $find('<%=CodeLightBox.ClientID %>');
        lightBox.show();
        var Text = lightBox.get_element().getElementsByClassName("demo");
        Text.CodeLightBox$RadTextBox1.control.set_value("new value");
    }
</script>

Thanks,
Princy.
0
Frank
Top achievements
Rank 1
answered on 07 Jan 2014, 03:41 PM
Thank you Princy!  I did not see the get_element() in the online documentation.  
0
Eduardo
Top achievements
Rank 1
answered on 23 Apr 2015, 07:55 PM

How do I access a template radlightbox in C # instead of the script below: 

<script type="text/javascript">    function OpenCodeLightBox() {        var lightBox = $find('<%=CodeLightBox.ClientID %>');        lightBox.show();        var Text = lightBox.get_element().getElementsByClassName("demo");        Text.CodeLightBox$RadTextBox1.control.set_value("new value");    }</script>

 

Tanks.

0
Angel Petrov
Telerik team
answered on 28 Apr 2015, 11:29 AM
Hello,

If you want to access the RadLigthtBox you can do this directly by using its ID. However if you want to access the RadTextBox inside the ItemTemplate of the first item you can do something like this.

C#:
RadTextBox textBox1=CodeLightBox.FindControl("RadTextBox1") as RadTextBox;


Regards,
Angel Petrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
LightBox
Asked by
Frank
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Frank
Top achievements
Rank 1
Eduardo
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or