RadControls for ASP.NET AJAX
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:
CopyASPX
<telerik:RadMenu ID="RadMenu1" runat="server" Flow="Horizontal">
<Items>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="Color">
<Items>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="ColorPicker">
<ItemTemplate>
<telerik:RadColorPicker ID="RadColorPicker1" runat="server" Preset="Standard" ShowEmptyColor="False">
</telerik:RadColorPicker>
</ItemTemplate>
<GroupSettings ExpandDirection="Auto" Flow="Vertical" />
</telerik:RadMenuItem>
</Items>
<GroupSettings ExpandDirection="Auto" Flow="Vertical" />
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>To access the RadColorPicker in the item template, use the following code:
CopyC#
RadMenuItem colorItem = RadMenu1.FindItemByText("ColorPicker"); RadColorPicker colors = (RadColorPicker)colorItem.FindControl("RadColorPicker1");
CopyVB.NET
Dim colorItem As RadMenuItem = RadMenu1.FindItemByText("ColorPicker")Dim colors As RadColorPicker = DirectCast(colorItem.FindControl("RadColorPicker1"), RadColorPicker)
CopyJavaScript
var menu = $find("<%= RadMenu1.ClientID %>");var item = menu.findItemByText("ColorPicker");var datePicker = item.findControl("RadColorPicker1");
or
CopyJavaScript
var datePicker = $find('<%= RadMenu1.FindItemByText("ColorPicker").FindControl("RadColorPicker1").ClientID %>');
See Also