MenuItem.ImageUrl Property
.NET Framework 2.0
Note: This property is new in the .NET Framework version 2.0.
Gets or sets the URL to an image that is displayed next to the text in a menu item.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
Use the ImageUrl property to specify a custom image for the current menu item in the Menu control. This image is displayed next to the menu item text and can be in any file format (.jpg, .gif, .bmp, and so on), as long as the client's browser supports that format.
The following code example demonstrates how to use the ImageUrl property to display a custom image next to the text of a menu item.
<%@ Page Language="C#" %> <html> <body> <form runat="server"> <h3>MenuItem Declarative Example</h3> <!-- Use declarative syntax to create the --> <!-- menu structure. Create submenu items --> <!-- by nesting them within parent menu --> <!-- items. --> <asp:menu id="NavigationMenu" staticdisplaylevels="1" staticsubmenuindent="10" orientation="Vertical" target="_blank" runat="server"> <items> <asp:menuitem navigateurl="Home.aspx" text="Home" imageurl="Images\Home.gif" popoutimageurl="Images\Popout.jpg" tooltip="Home"> <asp:menuitem navigateurl="Music.aspx" text="Music" popoutimageurl="Images\Popout.jpg" tooltip="Music"> <asp:menuitem navigateurl="Classical.aspx" text="Classical" separatorimageurl="Images\Separator.jpg" tooltip="Classical"/> <asp:menuitem navigateurl="Rock.aspx" text="Rock" separatorimageurl="Images\Separator.jpg" tooltip="Rock"/> <asp:menuitem navigateurl="Jazz.aspx" text="Jazz" separatorimageurl="Images\Separator.jpg" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem navigateurl="Movies.aspx" text="Movies" popoutimageurl="Images\Popout.jpg" tooltip="Movies"> <asp:menuitem navigateurl="Action.aspx" text="Action" separatorimageurl="Images\Separator.jpg" tooltip="Action"/> <asp:menuitem navigateurl="Drama.aspx" text="Drama" separatorimageurl="Images\Separator.jpg" tooltip="Drama"/> <asp:menuitem navigateurl="Musical.aspx" text="Musical" separatorimageurl="Images\Separator.jpg" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </form> </body> </html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.