以前一直使div来创建Vertical菜单,也曾有过3个版本。
现今Insus.NET抛开DIV标签生成的方法,使用a标签,而且是能动态添加的Vertical的网站左边菜单条。为了能够动态管理,莫非是把菜单的信息存储于数据库中,在网站的后管理页面能够添加,编辑,更新及删除这些菜单的信息。SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGO-- =============================================-- Author: Insus.NET-- Create date: 2013-07-22-- Description: site left menu .-- =============================================CREATE TABLE [dbo].[SiteMenu]( [SiteMenu_nbr] [tinyint] IDENTITY(1,1) NOT NULL, [MenuName] [nvarchar](30) NOT NULL, [Link] [varchar](200) NULL, [Target] [varchar](10) NULL,PRIMARY KEY CLUSTERED ( [SiteMenu_nbr] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFFGO
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: Insus.NET-- Create date: 2013-07-22-- Description: get all site left menu .-- =============================================CREATE PROCEDURE [dbo].[usp_SiteMenu_GetAll]ASSELECT [SiteMenu_nbr],[MenuName],[Link],[Target] FROM [dbo].[SiteMenu]GO
using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Web;////// Summary description for SiteMenu/// namespace Insus.NET{ public class SiteMenu { private byte _SiteMenu_nbr; private string _MenuName; private string _Link; private string _Target; public byte SiteMenu_nbr { get { return _SiteMenu_nbr; } set { _SiteMenu_nbr = value; } } public string MenuName { get { return _MenuName; } set { _MenuName = value; } } public string Link { get { return _Link; } set { _Link = value; } } public string Target { get { return _Target; } set { _Target = value; } } BusinessBase objBusinessBase = new BusinessBase(); public SiteMenu() { // // TODO: Add constructor logic here // } public DataTable GetAll() { return objBusinessBase.GetDataToDataSet("usp_SiteMenu_GetAll").Tables[0]; } }}
在菜单呈现之前,先写好菜单的样式:
菜单一般都是共用的,因此Insus.NET在演示时,把它放在MasterPage母版页内。创建一个母版页:下面是在.master.cs内,动态加载与绑定菜单的数据从数据库中。演示: