·您现在的位置: 江北区云翼计算机软件开发服务部 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> 从零开始编写自己的C#框架(18)——Web层后端权限模块——菜单管理
从本章开始,主要讲解的是页面中对框架相关功能的调用方法,比如列表页面(又分为有层次感列表和普通列表)、编辑页面、多标签页面等,只要熟悉了这些函数的使用方法,那么开发起来就会很便捷了。
1、如图先创建菜单列表与编辑页面
MenuInfoList.aspx
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MenuInfoList.aspx.cs" Inherits="Solution.Web.Managers.WebManage.Systems.Powers.MenuInfoList" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head id="Head1" runat="server"> 6 <title>菜单(页面)列表</title> 7 </head> 8 <body> 9 <form id="form1" runat="server">10 <f:pagemanager id="PageManager1" runat="server" />11 <f:panel id="Panel1" runat="server" title="菜单(页面)列表" enableframe="false" bodypadding="10px"12 enablecollapse="True">13 <toolbars>14 <f:Toolbar ID="toolBar" runat="server">15 <Items>16 <f:Button ID="ButtonRefresh" runat="server" Text="刷新" Icon="ArrowRefresh" OnClick="ButtonRefresh_Click" CSSClass="inline"></f:Button>17 <f:Button ID="ButtonAdd" runat="server" Text="添加" Icon="Add" OnClick="ButtonAdd_Click"></f:Button>18 <f:Button ID="ButtonSearch" runat="server" Text="查询" Icon="Magnifier" OnClick="ButtonSearch_Click"></f:Button>19 <%--<f:Button ID="ButtonEdit" runat="server" Text="编辑" Icon="BulletEdit" OnClick="ButtonEdit_Click"20 OnClientClick="if(!F('Panel1_Grid1').getSelectionModel().hasSelection()|| F('Panel1_Grid1').getSelectionModel().getCount()>=2){F.alert('您没有选择编辑项或只能选择一项进行编辑!'); return false; }">21 </f:Button>--%> 22 <f:Button ID="ButtonSaveAutoSort" runat="server" Text="自动排序" Icon="ArrowJoin" OnClick="ButtonSaveAutoSort_Click" ConfirmTitle="自动排序提示" ConfirmText="是否对所有数据进行自动排序?"></f:Button>23 <f:Button ID="ButtonSaveSort" runat="server" Text="保存排序" Icon="Disk" OnClick="ButtonSaveSort_Click"></f:Button>24 <f:Button ID="ButtonDelete" runat="server" Text="删除" Icon="Delete" OnClick="ButtonDelete_Click" ConfirmTitle="删除提示" ConfirmText="是否删除记录?" 25 OnClientClick="if (!F('Panel1_Grid1').getSelectionModel().hasSelection() ) { F.alert('删除时必须选择一条将要删除的记录!'); return false; } if (F('Panel1_Grid1').getSelectionModel().getCount() >= 2) { F.alert('只能选择一条记录进行删除!');return false; }">26 </f:Button>27 </Items>28 </f:Toolbar>29 </toolbars>30 <items>31 <f:SimpleForm ID="SimpleForm1" BodyPadding="5px" runat="server" EnableFrame="false" EnableCollapse="true"32 ShowBorder="True" ShowHeader="False">33 <Items>34 <f:DropDownList Label="菜单选择" runat="server" ID="ddlParentId" Width="250px"></f:DropDownList>35 </Items>36 </f:SimpleForm>37 <f:Grid ID="Grid1" Title="菜单列表" EnableFrame="false" EnableCollapse="true" AllowSorting="true" SortField="Depth" SortDirection="ASC"38 PageSize="15" ShowBorder="true" ShowHeader="true" AllowPaging="true" runat="server" EnableCheckBoxSelect="True" DataKeyNames="Id" EnableColumnLines="true"39 OnPageIndexChange="Grid1_PageIndexChange" OnPReRowDataBound="Grid1_PreRowDataBound" OnRowCommand="Grid1_RowCommand">40 <Columns>41 <f:RowNumberField />42 <f:BoundField Width="180px" DataField="Name" DataFormatString="{0}" DataSimulateTreeLevelField="Depth" HeaderText="菜单(页面)名" />43 <f:BoundField DataField="Url" HeaderText="访问路径" ExpandUnusedSpace="true" />44 <f:TemplateField HeaderText="排序" Width="100px">45 <ItemTemplate>46 <asp:TextBox ID="tbSort" runat="server" Width="50px" Text='<%# Eval("Sort") %>' AutoPostBack="false"></asp:TextBox>47 </ItemTemplate>48 </f:TemplateField>49 <f:LinkButtonField HeaderText="是否显示" Icon="BulletCross" TextAlign="Center" ToolTip="点击修改是否显示" ColumnID="IsDisplay" CommandName="IsDisplay" />50 <f:LinkButtonField HeaderText="是否页面" Icon="BulletCross" TextAlign="Center" ToolTip="点击修改是否页面" ColumnID="IsMenu" CommandName="IsMenu" />51 <f:BoundField DataField="Depth" HeaderText="级别层次" TextAlign="Center" />52 <f:LinkButtonField HeaderText="操作" TextAlign="Center" ToolTip="点击修改当前记录" ColumnID="ButtonEdit" CommandName="ButtonEdit" />53 </Columns>54 </f:Grid>55 <f:Label runat="server" ID="lblSpendingTime" Text=""></f:Label>56 <f:HiddenField runat="server" ID="SortColumn" Text="Id"></f:HiddenField>57 </items>58 </f:panel>59 <f:window id="Window1" width="480px" height="340px" icon="TagBlue" title="编辑" hidden="True"60 enablemaximize="True" closeaction="HidePostBack" onclose="Window1_Close" enablecollapse="true"61 runat="server" enableresize="true" bodypadding="5px" enableframe="True" iframeurl="about:blank"62 enableiframe="true" enableclose="true" plain="false" ismodal="True" enableconfirmonclose="True">63 </f:window>64 </form>65 </body>66 </html>View Code
MenuInfoList.aspx.cs
1 using System; 2 using System.Collections.Generic; 3 using DotNet.Utilities; 4 using FineUI; 5 using Solution.Dataaccess.DataModel; 6 using Solution.Logic.Managers; 7 using Solution.Web.Managers.WebManage.application; 8 9 namespace Solution.Web.Managers.WebManage.Systems.Powers 10 { 11 public partial class MenuInfoList : PageBase 12 { 13 #region Page_Load 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 if (!IsPostBack) 17 { 18 //绑定下拉列表 19 MenuInfoBll.GetInstence().BandDropDownList(this, ddlParentId); 20 21 LoadData(); 22 } 23 } 24 #endregion 25 26 #region 接口函数,用于UI页面初始化,给逻辑层对象、列表等对象赋值 27 public override void Init() 28 { 29 //逻辑对象赋值 30 bll = MenuInfoBll.GetInstence(); 31 //表格对象赋值 32 grid = Grid1; 33 } 34 #endregion 35 36 #region 加载数据 37 /// <summary>读取数据</summary> 38 public override void LoadData() 39 { 40 //设置排序 41 if (sortList == null) 42 { 43 Sort(); 44 } 45 46 //绑定Grid表格 47 bll.BindGrid(Grid1, InquiryCondition(), sortList); 48 } 49 50 /// <summary> 51 /// 查询条件 52 /// </summary> 53 /// <returns></returns> 54 p