Menu control : Menu « Asp Control « ASP.Net






Menu control


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Menu Samples</title>
</head>
<body>
    <form id="form1" runat="server">
   <div id="container">
      <asp:Menu id="menuOne" 
                runat="server" 
                DataSourceID="siteSource1" 
                BackColor="#B5C7DE" 
                DynamicHorizontalOffset="2" 
                Font-Names="Verdana" 
                Font-Size="1em" 
                ForeColor="#284E98" 
                StaticSubMenuIndent="10px" >
         <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
         <DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
         <DynamicMenuStyle BackColor="#B5C7DE" />
         <StaticSelectedStyle BackColor="#507CD1" />
         <DynamicSelectedStyle BackColor="#507CD1" />
         <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
         <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
      </asp:Menu>
      <br />
      <br />
      <br />      <br />      <br />


      <asp:SiteMapDataSource ID="siteSource1" runat="server" 
         ShowStartingNode="false"  />
         

   </div>
   </form>
</body>
</html>


File: Web.sitemap

<?xml version="1.0" encoding="utf-8" ?>
    
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
   
   <siteMapNode title="Home" description="Home Page" url="Default.aspx">
      <siteMapNode title="News" description="The Latest News" url="News.aspx">
         <siteMapNode title="U.S." description="U.S. News" url="News.aspx?cat=us" />
         <siteMapNode title="World" description="World News" url="News.aspx?cat=world" />
         <siteMapNode title="Technology" description="Technology News" url="News.aspx?cat=tech" />
         <siteMapNode title="Sports" description="Sports News" url="News.aspx?cat=sport" />
      </siteMapNode>
      <siteMapNode title="Weather" description="The Latest Weather" url="Weather.aspx" />
   </siteMapNode>
</siteMap>

 








Related examples in the same category

1.Using the MenuItemClick event (C#)
2.Using the MenuItemClick event (VB)
3.Using custom images
4.Applying divider images to dynamic items
5.A simple use of the Menu control
6.Style menu
7.Adding a hover style to static items in the menu control
8.Adding a hover style to dynamic items in the menu control
9.Forcing the menu items to use a horizontal orientation
10.Menu with CSS style
11.Menu style: Orientation, StaticSubMenuIndent
12.Data Binding with Menu Control
13.Menu style