15 Aralık 2012 Cumartesi

how to telerik:RadMenu show path


In order to view the selected path from your telerik RadMenu as in the picture below, you can use the following code:







aspx code:


<telerik:RadSiteMap ID="BreadCrumbSiteMap" runat="server" DataTextField="Text" DataNavigateUrlField="NavigateUrl">
        <DefaultLevelSettings ListLayout-RepeatDirection="Horizontal" SeparatorText="/" Layout="Flow" />
</telerik:RadSiteMap>



csharp code:


      protected void Page_Load(object sender, EventArgs e)
        {
            RadMenuItem currentItem = RadMenu.FindItemByUrl(Request.Url.PathAndQuery);
            if (currentItem != null)
            {
                currentItem.HighlightPath();
                DataBindBreadCrumbSiteMap(currentItem);
            }
            else
                RadMenu.Items[0].HighlightPath();
        }

        private void DataBindBreadCrumbSiteMap(RadMenuItem currentItem)
        {
            List breadCrumbPath = new List();
            while (currentItem != null)
            {
                breadCrumbPath.Insert(0, currentItem);
                currentItem = currentItem.Owner as RadMenuItem;
            }
            BreadCrumbSiteMap.DataSource = breadCrumbPath;
            BreadCrumbSiteMap.DataBind();
        }



The solution is from here: http://demos.telerik.com/aspnet-ajax/menu/examples/programming/showpath/defaultcs.aspx?Page=Blogs

Hiç yorum yok:

Yorum Gönder