现在做一个平台 一个viewport包含3部分 top west center
top中有3个button,每次点击一个都会重新加载一个导航放在west的panel中
但是在当点击button的时候,代码可以把west的内容给清空掉,但是新的menupanel添加不进去(在客户端显示不出来),代码没有异常(把代码放在pageload中可以很完美的显示出来),在网上找了很多的资料大多都是在pageload的时候加载一个导航就行了,没有这类似的效果,哪位大侠可以帮帮忙啊
代码是这样的
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %>
2
3 <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <html xmlns="http://www.w3.org/1999/xhtml">
6 <head runat="server">
7 <title></title>
8 <script type="text/javascript">
9
10 function setTab(obj){
11 Ext.get("CenterPanel").add({
12 title:obj,
13 id:obj,
14 html:obj,
15 closable:true
16 });
17
18 Ext.get("CenterPanel").setActiveTab(1);
19
20 }
21
22 function getTab(menu){
23
24
25 }
26
27 function addTab(id, url,title,icon) {
28 var tab = CenterPanel.getComponent(id);
29 if (!tab) {
30 tab = CenterPanel.add({
31 id: id,
32 title: title,
33 icon:icon,
34 closable:true,
35 autoLoad: {
36 showMask: true,
37 url: url,
38 mode:'iframe',
39
40 }
41 });
42
43 tab.on('activate', function() {
44
45 var item = Navigation.items.get(id);
46 if (item) {
47 Navigation.setSelection(item);
48 }
49
50 }, this);
51 }
52 CenterPanel.setActiveTab(tab);
53 }
54 </script>
55
56 </head>
57 <body>
58 <form runat="server">
59 <ext:ResourceManager runat="server">
60 </ext:ResourceManager>
61 <div>
62 <ext:Hidden ID="Hidden1" runat="server">
63 </ext:Hidden>
64 <ext:Viewport ID="ViewPort1" runat="server">
65 <Items>
66 <ext:BorderLayout ID="BorderLayout1" runat="server">
67 <North Collapsible="true" UseSplitTips="true" Split="true">
68 <ext:Panel ID="Panel1" runat="server" Header="false" Height="120" Html="<div style='width:100%;height:100%;background-image:url(../banner_02.jpg)'> <img src='../banner_01.jpg' style='float:left' /><img src='../banner_03.jpg'style='float:right' /></div>">
69 <BottomBar>
70 <ext:Toolbar ID="Toolbar1" runat="server">
71 <Items>
72 <ext:Button ID="Button1" runat="server" ToggleGroup="G1" Text="速报卡管理" CtCls="x-btn-over"
73 StyleSpec="margin-left:30px" Pressed="true">
74 <Listeners>
75 <Click Handler="Ext.net.DirectMethods.GetNav('1')" />
76 </Listeners>
77 </ext:Button>
78 <ext:ToolbarSeparator>
79 </ext:ToolbarSeparator>
80 <ext:Button ID="Button2" runat="server" ToggleGroup="G1" Text="系统权限" CtCls="x-btn-over"
81 StyleSpec="margin-left:5px">
82 <Listeners>
83 <Click Handler="Ext.net.DirectMethods.GetNav('2')" />
84 </Listeners>
85 </ext:Button>
86 <ext:ToolbarSeparator>
87 </ext:ToolbarSeparator>
88 <ext:Button ID="Button3" runat="server" ToggleGroup="G1" Text="地图配置管理" CtCls="x-btn-over"
89 StyleSpec="margin-left:5px">
90 <Listeners>
91 <Click Handler="Ext.net.DirectMethods.GetNav('3')" />
92 </Listeners>
93 </ext:Button>
94 <ext:ToolbarFill>
95 </ext:ToolbarFill>
96 <ext:Button ID="LinkButton1" runat="server" CtCls="x-btn-over" Text="退出登录">
97 <DirectEvents>
98 <Click OnEvent="logOut">
99 </Click>
100 </DirectEvents>
101 </ext:Button>
102 <ext:ToolbarSeparator>
103 </ext:ToolbarSeparator>
104 <ext:Button ID="LinkButton2" runat="server" CtCls="x-btn-over" Text="修改密码">
105 </ext:Button>
106 </Items>
107 </ext:Toolbar>
108 </BottomBar>
109 </ext:Panel>
110 </North>
111 <West MinWidth="100" MaxWidth="400" Split="true" Collapsible="true" >
112 <ext:Panel runat="server" Width="150" ID="Navigation" Title="速报卡" StyleSpec="backgroundColor:#dfe8f6;">
113 <LayoutConfig><ext:AccordionLayoutConfig Animate="true" /></LayoutConfig>
114 <Items>
115 <ext:MenuPanel runat="server" Title="速报卡" Border="false"
116 Icon="FolderGo" StyleSpec="backgroundColor:#dfe8f6;">
117 <Menu runat="server" StyleSpec="backgroundColor:#dfe8f6;">
118 <Items>
119 <ext:MenuItem Text="新增帐套" Href="#" Icon="Add">
120 <Listeners>
121 <Click Handler="addTab('idGgl', '/UpdPwd.aspx','新增帐套');" />
122 </Listeners>
123 </ext:MenuItem>
124 <ext:MenuItem Text="维护帐套" Href="#" Icon="Cmy" />
125 <ext:MenuItem Text="帐套备份" Href="#" Icon="DatabaseSave" />
126 <ext:MenuItem Text="帐套恢复" Href="#" Icon="DatabaseGo" />
127 </Items>
128 </Menu>
129 </ext:MenuPanel>
130 <ext:MenuPanel ID="MenuPanel1" runat="server" Title="速报卡" Border="false"
131 Icon="FolderGo">
132 <Menu runat="server" StyleSpec="backgroundColor:#dfe8f6;">
133 <Items>
134 <ext:MenuItem Text="新增帐套" Href="#" Icon="Add">
135 <Listeners>
136 <Click Handler="addTab('idGgl', '/UpdPwd.aspx','新增帐套','Add');" />
137 </Listeners>
138 </ext:MenuItem>
139 <ext:MenuItem Text="维护帐套" Href="#" Icon="Cmy" />
140 <ext:MenuItem Text="帐套备份" Href="#" Icon="DatabaseSave" />
141 <ext:MenuItem Text="帐套恢复" Href="#" Icon="DatabaseGo" />
142 </Items>
143 </Menu>
144 </ext:MenuPanel>
145
146 </Items>
147 </ext:Panel>
148 </West>
149 <Center MarginsSummary="0,0,0,0">
150 <ext:TabPanel ID="CenterPanel" runat="server" TabMargin="0" AutoDestroy="true" EnableTabScroll="true">
151 <Items>
152 <ext:Panel ID="CenterTab1" runat="server" Title="Center" Border="false" BodyStyle="padding:6px;">
153 </ext:Panel>
154 </Items>
155 </ext:TabPanel>
156 </Center>
157 </ext:BorderLayout>
158 </Items>
159 </ext:Viewport>
160 </div>
161 </form>
162 </body>
163 </html>
164
后台是这样的
1 IList<NavInfo> list = new List<NavInfo>();//list的值从其他地发光获取
2
3 Ext.Net.MenuPanel m = new Ext.Net.MenuPanel();
4 m.Title = this.Navigation.Title;
5 m.StyleSpec = "backgroundColor:#dfe8f6";
6 m.Icon = Icon.DatabaseSave;
7 m.RenderTo = Navigation.ClientID;
8 m.Border = false;
9
10 foreach (NavInfo item in list)
11 {
12 Ext.Net.MenuItem menuitem = new Ext.Net.MenuItem();
13 menuitem.ID = "mitem"+item.ID;
14 menuitem.Text = item.Text;
15 menuitem.Href = "#";
16 menuitem.Icon = Icon.Add ;
17
18 menuitem.Listeners.Click.Handler = "addTab('" + menuitem.ClientID + "','" + item.Url +"','"+item.Text +"','Add')";
19 m.Menu.Items.Add(menuitem);
20 }
21
22 Navigation.Add(m);
23 m.Render();
24 CenterPanel.DoLayout();
25
来回点击头部左边3个button(每个button出现的左边导航都不一样),会出现一下情况见图片,图片右边内容就有item出现了。。。