FineUI 官方论坛
标题:
关于手风琴控件的问题,请大家帮忙
[打印本页]
作者:
不回头的执着
时间:
2013-8-4 22:46
标题:
关于手风琴控件的问题,请大家帮忙
首次加载[attach]2858[/attach]点击后[attach]2857[/attach]
aspx页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Menu.aspx.cs" Inherits="WEB.Menu" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<x:PageManager ID="PageManager1" runat="server" AutoSizePanelID="RegionPanel1" />
<x:RegionPanel ID="RegionPanel1" runat="server">
<Regions>
<x:Region ID="Region1" runat="server" Position="Left" ShowHeader="true" Split="true" Title="管理导航" Width="200px" BodyPadding="0 0 5 0" BoxConfigPadding="0 0 5 0">
</x:Region>
</Regions>
</x:RegionPanel>
</form>
</body>
</html>
复制代码
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WEB
{
public partial class Menu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<SAMS.Model.MENU> listm = new SAMS.BLL.MENU().GetModelList("FatherMenuID is null");
var menuAccordion = new FineUI.Accordion();
menuAccordion.EnableFill = true;
menuAccordion.ShowHeader = false;
this.Region1.Items.Add(menuAccordion);
for (int i = 0; i < listm.Count; i++)
{
var accpan = new FineUI.AccordionPane();
accpan.Title = listm[i].MenuMingCheng;
//accpan.ID = "accpan" + i;
accpan.BodyPadding = "2px 0 0 0";
accpan.ShowHeader = false;
FineUI.Tree tree = BindTopMenu(listm[i].MenuID);
menuAccordion.Items.Add(accpan);
accpan.Items.Add(tree);
}
}
/// <summary>
/// 绑定树型菜单的顶级菜单
/// </summary>
/// <param name="fid">顶级菜单的菜单ID</param>
/// <returns></returns>
protected FineUI.Tree BindTopMenu(int fid)
{
List<SAMS.Model.MENU> listm=null;
if (fid == 0)
{
listm = new SAMS.BLL.MENU().GetModelList("");
}
else
{
listm = new SAMS.BLL.MENU().GetModelList("MenuID=" + fid);
}
var treeMenu = new FineUI.Tree();
for (int i = 0; i < listm.Count; i++)
{
var node = new FineUI.TreeNode();
node.NavigateUrl = listm[i].MenuURL;
node.Text = listm[i].MenuMingCheng;
node.NodeID = listm[i].MenuID.ToString();
BindMenuTree(treeMenu, node);
treeMenu.Nodes.Add(node);
}
return treeMenu;
}
/// <summary>
/// 绑定树型菜单的下级菜单
/// </summary>
/// <param name="tree">树ID</param>
/// <param name="currentNode">当前节点</param>
protected void BindMenuTree(FineUI.Tree tree, FineUI.TreeNode currentNode)
{
List<SAMS.Model.MENU> subMenu = new SAMS.BLL.MENU().GetModelList("FatherMenuID=" + currentNode.NodeID);
if (subMenu.Count == 0)
{
return;
}
else
{
for (int i = 0; i < subMenu.Count; i++)
{
var node = new FineUI.TreeNode();
node.NavigateUrl = subMenu[i].MenuURL;
node.Text = subMenu[i].MenuMingCheng;
node.NodeID = subMenu[i].MenuID.ToString();
BindMenuTree(tree,node);
node.ParentNode = currentNode;
tree.Nodes.Add(node);
}
}
}
}
}
复制代码
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4