Click to See Complete Forum and Search --> : Menu control - customization


fireblade
09-27-2007, 12:41 PM
is there a way to customize the menu control in ASP.NET 2.0? how can I add images & roLLover images for the background of the Menu?
I will be very thankfull if anyone can give me an easy to understand way.

I tried in google search. some are said to buy their own control for cash which they have made for easyto customize:eek: . And some others says that this version of ASP.NET doesnt contain a customizable way. may be the next version will deliver such a control. is this true? so cant I customize my menu controL?:confused:

lmf232s
09-27-2007, 01:23 PM
I added images to the menu control like this. Also to note in my web.sitemap i added new properties for the title and img property that im using here.

This code goes on the page that is creating the menu control

Protected Sub menua_MenuItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles menua.MenuItemDataBound
Dim mapNode As SiteMapNode = CType(e.Item.DataItem, SiteMapNode)
If Not (mapNode("img") Is Nothing) Then
e.Item.Text = mapNode("Title")
e.Item.ImageUrl = mapNode("img")
End If
End Sub


'Example of the web.sitemap. Notice the Title and the Img property that I added. This is what im reading in the code above.

<!--HOME-->
<siteMapNode title=" Home" url="~/Default.aspx" description="E.T Phone Home" img="~/images/home_sm.gif">
<!--ADMIN-->
<siteMapNode title=" Admin" url="~/Admin/Default.aspx" description="Access Admin Control Panel" img="~/images/icon_securityroles_16px.gif">


This will only get you an initial image on your menu and does not deal with the hover and changing the image but this might lead you in the right direction.

fireblade
09-27-2007, 01:28 PM
thnks,,, i wiLL check your code and repLy to this thread.