New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

RadLightBox ItemTemplate FindControl ?

Environment

Product RadLightBox for ASP.NET AJAX

Description

How can I access controls placed within the ItemTemplate of RadLightBox?

   <telerik:RadLightBox ID="LightBox1" runat="server">
        <Items>
            <telerik:RadLightBoxItem>
                <ItemTemplate>
                    <telerik:RadTextBox ID="RadTextBox2" runat="server" />
                </ItemTemplate>
            </telerik:RadLightBoxItem>
        </Items>
    </telerik:RadLightBox>

Solution

There are several ways of achieving this requirement:

    protected void RadTextBox2_Load(object sender, EventArgs e)
    {
        RadTextBox textBox = sender as RadTextBox;
        textBox.Text = "Success";
    }

Alternatively, you can also use this approach:

    protected void Page_PreRender(object sender, EventArgs e)
    {
        RadTextBox textBox = LightBox1.FindControl("RadTextBox2") as RadTextBox;
        textBox.Text = "Success 2";
    }

For accessing the controls or elements on client-side you can check the findControl and findElement methods provided here: Access Telerik Controls on Client-Side

In this article