New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Select (highlight) the current page in the RadMenu
Description
When the client navigates to a page, if there is an item with NavigateUrl equal to the path in the address bar, it should be highlighted.
Solution
This functionality comes out of the box for Menu bound to a SiteMapDataSource. This is because only in this scenario the NavigateUrl is automatically populated. For other databinding scenarios, the NavigateUrl should be populated by setting the DataNavigateUrlField property.
Then, in the ItemDataBound event show the path to the item if its NavigateUrl is the same as the Request.Path property.
C#
protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
{
RadMenuItem item = e.Item;
string path = item.NavigateUrl;
if (string.Equals(path, Request.Path, StringComparison.OrdinalIgnoreCase))
{
item.HighlightPath();
}
}