Eight years old, but I have a slightly different solution, based on the solution @Jayesh provided. Nothing in the ASPX page at all, since the event is handled in Page_Load.
ASPX.CS:
protected void Page_Load(object sender, EventArgs e)
{
if(Page.IsPostBack)
{
return;
}
Telerik.Web.UI.RadMenu topLevel = RadMenu1;
foreach(RadMenuItem item in topLevel.Items)
{
LookForRadMenuItems(item);
}
}
private void LookForRadMenuItems(RadMenuItem sender)
{
if(sender.Text == "Honda")
{
sender.Visible = false;
}
foreach(RadMenuItem item in sender.items)
{
LookForRadMenuItems(item);
}
}
This will look for all instances of "Honda" in all menus and submenus, and hide them. You can make it more flexible, by checking if the text .contains
"Honda" instead, for instance, or creating a dictionary or hashtable for looking for more than one item at a time.
My particular application is actually in VB.NET, so here is the code equivalent for that:
VB.NET
Protected Sub Page_Load(sender As Object, e As System.EventArgs)
If Page.IsPostBack Then Exit Sub
Dim topLevel As Telerik.Web.UI.RadMenu = RadMenu1
For Each item As RadMenuItem In topLevel.Items
LookForRadMenuItems(item)
Next
End Sub
Private Sub LookForRadMenuItems(sender as RadMenuItem)
If sender.Text = "Honda" Then
sender.Visible = false
End If
For Each(item As RadMenuItem In sender.Items)
LookForRadMenuItems(item)
Next
End Sub