This is a migrated thread and some comments may be shown as answers.

How to add Image into the Menu created using Sitemap

5 Answers 243 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lakul
Top achievements
Rank 1
Lakul asked on 07 Sep 2010, 07:32 PM
Hi,

I have created Menu using Sitemap.

SITEMAP CODE

 <siteMapNode title="MainMenuItem">                 
                  <siteMapNode controller="subController1" action="Index" title="SubMenu1"/>
                  <siteMapNode controller="subController2" action="Index" title="SubMenu2" />
                  <siteMapNode controller="subController3" action="Index" title="SubMenu3" />
  </siteMapNode>

Telerik Code is:
 Html.Telerik().Menu().Name("MyMenu").BindTo("web").Orientation(MenuOrientation.Vertical).Render()

how can i add image to MainMenuItem or SubMenuItem of Menu

Thanks,
Lakul

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 08 Sep 2010, 12:20 PM
Hello Lakul,

In order to achieve your goal you will need to use SiteMapNode.Attributes collection:

[View]:
<%= Html.Telerik().Menu()
       .Name("Menu")
       .BindTo("sample", (item, node) => {
           var url = node.Attributes["imageurl"];
           if(url != null)
            item.ImageUrl = node.Attributes["imageurl"].ToString();
       })
%>

[Sitemap]:
<siteMapNode title="MainMenuItem">                
                 <siteMapNode controller="subController1" action="Index" title="SubMenu1" imageurl="imageurl"/>
                 <siteMapNode controller="subController2" action="Index" title="SubMenu2" />
                 <siteMapNode controller="subController3" action="Index" title="SubMenu3" />
 </siteMapNode>

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lakul
Top achievements
Rank 1
answered on 08 Sep 2010, 05:05 PM
Thanks Georgi Krustev
0
Sysdata Labs
Top achievements
Rank 1
answered on 11 Nov 2010, 11:49 PM
Thanks! This is exactly what I was looking for. Works great.
0
steve
Top achievements
Rank 1
answered on 13 Dec 2010, 03:44 PM
I am wondering if I can use sitemapnode attributes to add change the class, id, or border styles.  Because the telerik menu automatically sets all of items in my menu to be in the same class, I cannot customize the border for an individual item.  If I can change the class on one item, then I could change the css to edit the border. Or, if I can change the border from the site map, that would also work.  If anyone knows a solution, please share.  Thank you.
0
Sysdata Labs
Top achievements
Rank 1
answered on 16 Apr 2011, 08:54 PM

I was able to fully customize the layout of the Menu controller by setting custom formatting for the exact CSS class the controller renders. I used Google Chrome's developer tools to find the right CSS class name. From Chrome, just click "Ctrl + Shift + I" and hover over the menu controller. Good luck!

Tags
Menu
Asked by
Lakul
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Lakul
Top achievements
Rank 1
Sysdata Labs
Top achievements
Rank 1
steve
Top achievements
Rank 1
Sysdata Labs
Top achievements
Rank 1
Share this question
or