Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir, i am using asp menu with xml data soucse. and my asp menu and xml code look like that:-



ASP.NET
<asp:Menu ID="mnuNavigation" runat="server" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
    <StaticMenuStyle CssClass="StaticMenuItem" />
    <StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
    <StaticHoverStyle CssClass="StaticHoverStyle" />
    <StaticSelectedStyle CssClass="StaticSelectedStyle" />
    <DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />
    <DynamicHoverStyle CssClass="DynamicHoverStyle" />
    <DynamicSelectedStyle CssClass="DynamicSelectedStyle" />
</asp:Menu>



XML
<?xml version="1.0" encoding="utf-8" ?>
<Pages>
  <Student title="Student" url="Student" >

 <Library title="Library" url="Library">
      <Page title="Book Accession" url="Library/bookacc.aspx"></Page>
      <Page title="Accession Report" url="Library/DateRange.aspx"></Page>
    </Library>

  </Student>
</Pages>



my asp menu look very simple.. i want to add icons in my each menu item. can u help me to guide that how can i add icons in each menu item.

What I have tried:

i have a asp menu with xml data datasource. when ever i added an page in xml it show in mu asp menu.. but i wamt to add icon also in my menu item names..
Posted
Updated 21-Feb-16 2:12am
v2
Comments
Afzaal Ahmad Zeeshan 21-Feb-16 3:55am    
How are you building the menu? Show us that code and we may help you to build the menu.
Maciej Los 21-Feb-16 5:01am    
Please, use "Improve question" widget to upgrade your question with code and link to the referenced article.
TCS54321 21-Feb-16 5:11am    
sir i am using web.xml page in asp.net project to add menu in asp menu. it look very simple.. i need to add icon with each menu items.

1 solution

Try with below steps:

Step1: Design XML menu with below data. Just add one extra node Image in xml:
XML
<menus>
    <menu image="images.png" url="~/Home.aspx" text="Home" value="Home Page" />
    <menu image="images.png" url="javascript:;" text="Services" value="Services Page">
        <submenu image="images.png" url="~/Consulting.aspx" text="Consulting" value="Consulting Page"></submenu>
        <submenu image="images.png" url="~/Outsourcing.aspx" text="Outsourcing" value="Outsourcing Page"></submenu>
    </menu>
    <menu image="images.png" url="~/About.aspx" text="About" value="About Us Page" />
    <menu image="images.png" url="~/Contact.aspx" text="Contact" value="Contact Us Page" />
</menus>

Step2: Design ASP menu to bind xml data and use ImageUrlField property which will refer to "Image" node value in xml:
ASP.NET
<asp:menu id="Menu1" runat="server" orientation="Horizontal" datasourceid="XmlDataSource1" xmlns:asp="#unknown">
	<levelmenuitemstyles>
		<asp:menuitemstyle cssclass="main_menu" />
		<asp:menuitemstyle cssclass="level_menu" />
	</levelmenuitemstyles>
	<staticselectedstyle cssclass="selected" />
	<databindings>
		<asp:menuitembinding imageurlfield="Image" datamember="Menu" textfield="Text" valuefield="Value" navigateurlfield="Url" />
		<asp:menuitembinding datamember="SubMenu" textfield="Text" valuefield="Value" navigateurlfield="Url" />
	</databindings>
</asp:menu>
<asp:xmldatasource id="XmlDataSource1" runat="server" datafile="~/Menus.xml" xpath="/Menus/Menu" xmlns:asp="#unknown"></asp:xmldatasource>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900