asp.net Menu: how to use (site map ex)
Menu.aspx
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Menu.aspx.cs" Inherits="Menu" %>
- <!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>asp.net Menu: how to use</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <h2 style="color:Red">Menu</h2>
- <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
- <asp:Menu ID="Menu1" runat="server">
- </asp:Menu>
- </div>
- </form>
- </body>
- </html>
Menu.aspx.cs
- using System;
- using System.Collections;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Linq;
- public partial class Menu : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if(!this.IsPostBack)
- {
- Menu1.DataSourceID = "SiteMapDataSource1";
- Menu1.BackColor = System.Drawing.Color.Green;
- Menu1.ForeColor = System.Drawing.Color.Snow;
- Menu1.DynamicMenuStyle.BackColor = System.Drawing.Color.OrangeRed;
- }
- }
- }
Web.sitemap
No comments:
Post a Comment