Edit this page

Accessing Controls Inside Templates

If your RadMenu has items with templates that have embedded controls, you may want to access the properties of those embedded controls. To get a reference to the embedded control, locate the RadMenuItem that has the template, and use its FindControl method.

For example, consider the following, very simple, menu:

<telerik:RadMenu RenderMode="Lightweight" ID="RadMenu1" runat="server" Flow="Horizontal">
        <telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="Color">
                <telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="ColorPicker">
                        <telerik:RadColorPicker RenderMode="Lightweight" ID="RadColorPicker1" runat="server" Preset="Standard" ShowEmptyColor="False">
                    <GroupSettings ExpandDirection="Auto" Flow="Vertical" />
            <GroupSettings ExpandDirection="Auto" Flow="Vertical" />

To access the RadColorPicker in the item template, use the following code:

Server-side access

RadMenuItem colorItem = RadMenu1.FindItemByText("ColorPicker"); 
RadColorPicker colors = (RadColorPicker)colorItem.FindControl("RadColorPicker1");
Dim colorItem As RadMenuItem = RadMenu1.FindItemByText("ColorPicker")
Dim colors As RadColorPicker = DirectCast(colorItem.FindControl("RadColorPicker1"), RadColorPicker)

Client-side access

var menu = $find("<%= RadMenu1.ClientID %>"); var item = menu.findItemByText("ColorPicker");
var datePicker = item.findControl("RadColorPicker1");


var datePicker = $find('<%= RadMenu1.FindItemByText("ColorPicker").FindControl("RadColorPicker1").ClientID %>');          

See Also

Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article