《asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发3-登录模块开发》教程中已经讲解了登录模块,登录成功后就要调整的后台管理页面了,《asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发4- 后台模板html页面创建》这篇文件中我们创建了后台管理模板页,本文讲解将我们创建的静态模板页集成到我们的项目中去,最终效果如下:
我们先看我们登录代码最后跳转到的页面代码:return Redirect("/Home/AdminIndex");,不难看出最后跳转到了HomeController下面的AdminIndex方法内。
所以我们需要首先创建HomeController控制器,然后在控制器内新增AdminIndex方法。
在解决方案资源管理器的Controllers文件夹上右键单击,选择添加》控制器菜单:打开新增控制器对话框,如下图:
点击添加按钮即可,然后将里面默认Index方法更名为AdminIndex即可,最终得到的代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
|
namespace SiteDataBase.Controllers { public class HomeController : Controller { // 后台管理首页 public ActionResult AdminIndex() { return View(); } } } |
在AdminIndex方法内部右键单击,选择添加视图菜单,创建AdminIndex方法对应的视图页面,如下图所示:
最后得到如下页面:
集成后台HTML静态页面之前需要将相关的资源库拷贝到项目中,将《asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发4- 后台模板html页面创建》教程内创建的Css、Images、Js三个文件夹拷贝到项目的Content文件夹下面,拷贝方法复制三个文件夹,然后在解决方案资源管理器的Content文件夹上面右键单击选择粘贴菜单,此时项目目录结构如下:
1、拷贝静态页面代码覆盖新增的AdminIndex文件代码,主要需要保留
1
2
3
|
@{ Layout = null ; } |
代码,此代码的作用说明这个页面不使用任何模板,必要有。
最终得到代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
@{ Layout = null; } <!DOCTYPE html> < html > < head > < title >网站后台模板</ title > < meta charset = "utf-8" > < meta name = "viewport" content = "width=device-width,initial-scale=1,user-scalable=no" > < script src = "Js/jquery-1.7.1.min.js" ></ script > < script src = "Js/jquery.easyui.min.js" type = "text/javascript" ></ script > < link href = "Css/themes/default/easyui.css" rel = "stylesheet" /> < link href = "Css/themes/icon.css" rel = "stylesheet" /> < link href = "Css/Public.css" rel = "stylesheet" /> < link href = "Css/Index.css" rel = "stylesheet" /> < script src = "Js/ShowMyWindow.js" ></ script > < script type = "text/javascript" > function windowClose() { $('#myWindow').window('close'); $.messager.alert('提示信息', '密码修改成功,请重新登录!', 'info'); window.location.href = '/Login/AdminLogin'; } $(document).ready(function () { $('.easyui-accordion li a').click(function () { var tabTitle = $(this).text();//tab标题 var url = $(this).attr("href");//tab连接 addTab(tabTitle, url); $('.easyui-accordion li div').removeClass("selected"); $(this).parent().addClass("selected"); }).hover(function () { $(this).parent().addClass("hover"); }, function () { $(this).parent().removeClass("hover"); }); function addTab(subtitle, url) { if (!$('#tabs').tabs('exists', subtitle)) { $('#tabs').tabs('add', { title: subtitle, content: createFrame(url), closable: true, cache: true, width: $('#mainPanle').width() - 10, height: $('#mainPanle').height() - 26, tools: [{ iconCls: 'icon-reload', handler: function () { refreshTab(); } }] }); } else { $('#tabs').tabs('select', subtitle); } tabClose(); tabCloseEven(); } //切换选项卡刷新 $('#tabs').tabs({ onSelect: function (title, index) { refreshTab(); } }); //刷新当前选项卡 function refreshTab() { var currTab = self.parent.$('#tabs').tabs('getSelected'); //获得当前tab var url = $(currTab.panel('options').content).attr('src'); if (url == undefined) url = "/Statistics/CountyStatistics"; self.parent.$('#tabs').tabs('update', { tab: currTab, options: { content: createFrame(url) } }); } function createFrame(url) { var s = '< iframe name = "mainFrame" scrolling = "auto" frameborder = "0" src = "' + url + '" style = "width:100%;height:100%;" ></ iframe >'; return s; } function tabClose() { /*双击关闭TAB选项卡*/ $(".tabs-inner").dblclick(function () { var subtitle = $(this).children("span").text(); $('#tabs').tabs('close', subtitle); }) //绑定右键菜单 $(".tabs-inner").bind('contextmenu', function (e) { $('#mm').menu('show', { left: e.pageX, top: e.pageY, }); var subtitle = $(this).children("span").text(); $('#mm').data("currtab", subtitle); return false; }); } //绑定右键菜单事件 function tabCloseEven() { //刷新 $('#mm-refresh').click(function () { refreshTab(); }) //关闭当前 $('#mm-tabclose').click(function () { var currtab_title = $('#mm').data("currtab"); $('#tabs').tabs('close', currtab_title); }) //全部关闭 $('#mm-tabcloseall').click(function () { $('.tabs-inner span').each(function (i, n) { var t = $(n).text(); $('#tabs').tabs('close', t); }); }); //关闭除当前之外的TAB $('#mm-tabcloseother').click(function () { var currtab_title = $('#mm').data("currtab"); $('.tabs-inner span').each(function (i, n) { var t = $(n).text(); if (t != currtab_title) $('#tabs').tabs('close', t); }); }); //关闭当前右侧的TAB $('#mm-tabcloseright').click(function () { var nextall = $('.tabs-selected').nextAll(); if (nextall.length == 0) { //msgShow('系统提示','后边没有啦~~','error'); //alert('后边没有啦~~'); return false; } nextall.each(function (i, n) { var t = $('a:eq(0) span', $(n)).text(); $('#tabs').tabs('close', t); }); return false; }); //关闭当前左侧的TAB $('#mm-tabcloseleft').click(function () { var prevall = $('.tabs-selected').prevAll(); if (prevall.length == 0) { //alert('到头了,前边没有啦~~'); return false; } prevall.each(function (i, n) { var t = $('a:eq(0) span', $(n)).text(); $('#tabs').tabs('close', t); }); return false; }); //退出 $("#mm-exit").click(function () { $('#mm').menu('hide'); }) } $("#exitSystem").click(function () { window.location.href = "/Login/AdminLoginOff"; }); $("#modifyPassSystem").click(function () { showMyWindow("修改密码", "http://www.baidu.com", 500, 350); }); }); </ script > </ head > < body > < body class = "easyui-layout" > < div class = "clear" ></ div > < div region = "north" border = "true" split = "true" style = "overflow: hidden; height: 80px;" > < div class = "top" > < div class = "button-tools" > < div class = "exit-system" >< a id = "exitSystem" class = "easyui-linkbutton" data-options = "iconCls:'icon-cancel'" >安全退出</ a ></ div > < div class = "exit-system" >< a id = "modifyPassSystem" target = "mainFrame" class = "easyui-linkbutton" data-options = "iconCls:'icon-key-delete'" >修改密码</ a ></ div > < div class = "exit-system" > < div class = "curUserInfo" >当前登录用户:Admin</ div > </ div > </ div > </ div > </ div > < div region = "south" border = "true" split = "true" style = "overflow: hidden; height: 40px;" > </ div > < div region = "west" split = "true" title = "导航菜单" style = "width: 200px;" > < div id = "menu-content" class = "easyui-accordion" style = "position: absolute; top: 27px; left: 0px; right: 0px; bottom: 0px;" > < div title = "文章管理" iconcls = "icon-folder-page" style = "overflow: auto; padding: 0px;" > < ul > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >文章管理</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >栏目管理</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >专题管理</ span ></ a ></ div > </ li > </ ul > </ div > < div title = "会员管理" iconcls = "icon-folder-page" style = "overflow: auto; padding: 0px;" > < ul > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >会员管理</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >订单管理</ span ></ a ></ div > </ li > </ ul > </ div > < div title = "系统管理" iconcls = "icon-folder-page" style = "overflow: auto; padding: 0px;" > < ul > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >友情链接</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >用户管理</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >角色管理</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >日志管理</ span ></ a ></ div > </ li > < li > < div class = "" >< a target = "mainFrame" href = "http://www.baidu.com" >< span class = "defined-icon icon-chart-organisation" > </ span >< span class = "nav" >预约参观</ span ></ a ></ div > </ li > </ ul > </ div > </ div > </ div > < div id = "mainPanle" region = "center" style = "overflow: hidden;" > < div id = "tabs" class = "easyui-tabs" fit = "true" border = "false" > </ div > < div id = "mm" class = "easyui-menu" style = "width: 150px;" > < div id = "mm-refresh" >刷新</ div > < div class = "menu-sep" ></ div > < div id = "mm-tabclose" >关闭</ div > < div id = "mm-tabcloseall" >全部关闭</ div > < div id = "mm-tabcloseother" >除此之外全部关闭</ div > < div class = "menu-sep" ></ div > < div id = "mm-tabcloseright" >当前页右侧全部关闭</ div > < div id = "mm-tabcloseleft" >当前页左侧全部关闭</ div > < div class = "menu-sep" ></ div > < div id = "mm-exit" >退出</ div > </ div > </ div > </ body > </ html > |
此时还需要将文件内资源文件进行重新引用,因为目录结构发生变化,最终如下:
引用方法直接从解决方案管理器中拖动到文件内即可。
运行查看效果:
因为用户库还没有用户信息,此时还不能从用户登录页面跳转到此页面,要想查看页面效果需要修改RouterConfig.cs文件内的默认路由,方可运行
1
2
3
4
5
6
7
8
9
10
11
|
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" ); routes.MapRoute( "Default" , // 路由名称 "{controller}/{action}/{id}" , // 带有参数的 URL new { controller = "Home" , action = "AdminIndex" , id = UrlParameter.Optional } // 参数默认值 ); } |
最终运行效果如下:
- 完美解决iis下JWplayer提示Error loading media: File could not be played错误(3701)
- asp.net mvc+jquery easyui开发基础(一)模块首页及增加、修改、删除模块实现(2926)
- .Net Mvc中使用Jquery EasyUI控件讲解(一)表格控件datagrid使用介绍(2633)
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(三)登录模块开发(2577)
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(七)权限管理模块之系统菜单动态生成(2541)
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(六)权限管理模块之初始数据准备(2191)
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(八)权限管理模块之权限管理实现(2158)
- Jquery ajax访问asp.net web api跨域问题解决方案(1829)
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(五)后台模板html页面集成到项目中(1609)
- .Net Mvc中使用Jquery EasyUI控件讲解(二)树形控件tree使用介绍(1535)
- 1. Windows Server 2008 R2永久激活及Chew-WGA v0.9下载(12642)
- 2.Visual Studio 2017中安装visualSVN及使用详解(4838)
- 3.完美解决iis下JWplayer提示Error loading media: File could not be played错误(3701)
- 4.asp.net mvc+jquery easyui开发基础(一)模块首页及增加、修改、删除模块实现(2926)
- 5.Android avax.net.ssl.SSLPeerUnverifiedException: No peer certificate 解决方法(httpClient支持HTTPS的访问方式)(2791)
- 6..Net Mvc中使用Jquery EasyUI控件讲解(一)表格控件datagrid使用介绍(2633)
- 7.asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(三)登录模块开发(2577)
- 8.asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(七)权限管理模块之系统菜单动态生成(2541)
- 9. asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(六)权限管理模块之初始数据准备(2191)
- 10.asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发(八)权限管理模块之权限管理实现(2158)