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

RadMenu with SiteMap and Image

3 Answers 327 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 08 Feb 2009, 05:26 PM

Hi all,

 

I'm using the web.sitemap as the source for the RadMenu and would like to also have a small icon (.gif/.jpg) to the menu items. I've seen examples of either all images or just with the sitemap.  Does anyone have an integrated example?  Telerik's Courseware showed a great potential use of it with a graphic icon next to the sub item but no code sample.

Thank you very much.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Feb 2009, 05:59 PM
Hello Ninh Nguyen,

You can use the attributes of the sitemap node to set the image and then the ItemDataBound event of the menu. Here is a code snippet:

web.sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="test" title="test"  description="test" image="test.gif">
    </siteMapNode>
</siteMap>

codebehind:

    protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
    {
        e.Item.ImageUrl = ((SiteMapNode) e.Item.DataItem)["image"];
    }
Best wishes,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David Moore
Top achievements
Rank 1
answered on 24 Sep 2009, 09:12 PM
I am trying to do the same thing, this will only return a null value.

protected void testMenu_ItemDataBound(object sender, RadMenuEventArgs e) 
    { 
        RadMenuItem item = e.Item; 
        SiteMapNode smn = (SiteMapNode)e.Item.DataItem; 
 
        string test = ((SiteMapNode)e.Item.DataItem)["url"]; 
    } 

This returns null even using URL, along with any other attribute I attempt to do this with.


0
Atanas Korchev
Telerik team
answered on 25 Sep 2009, 07:39 AM
Hello David Moore,

If you are using the example I've sent you must use Attributes["image"] not Attributes["url"].

Regards,
Albert,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Menu
Asked by
Michael
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
David Moore
Top achievements
Rank 1
Share this question
or