一、用户
二、用户组
2.1浏览用户组
2.2添加用户组
2.3修改用户组
2.4删除用户组
删除用户组相对简单些,不用单独的页面,直接在浏览页面点击删除时,弹出确认删除对话框,点击确认,用jquery post删除。
打开【UserGroupController】,删掉public ActionResult Delele(int GroupId) { return View(); }
修改删除处理Action[Delete(int Id)],修改后的代码
/// <summary> /// 删除用户组 /// </summary> /// <param name="Id">用户组Id</param> /// <returns></returns> [HttpPost] [AdminAuthorize] public JsonResult Delete(int Id) { userGroupRsy = new UserGroupRepository(); if (userGroupRsy.Delete(Id)) return Json(true); else return Json(false); }
这里返回类型为JsonResult目的方便使用jquery 的post方式删除。
打开List.cshtml,将@Html.ActionLink("删除", "Delete", new { id = item.UserGroupId }) 改为<a href="javascript:void(0)" onclick="Delete(@item.UserGroupId,'@item.Name')" >删除</a>
在文件底部添加脚本
function Delete(id,name) { if (confirm("你确定要删除【" + name + "】吗?")) { $.post("@Url.Content("~/UserGroup/Delete")", {Id:id}, function (data) { if (data) { alert("删除【" + name + "】成功!"); location.reload(); } }); } }
完成后整个List.cshtml的代码如下:
@model IEnumerable<Ninesky.Models.UserGroup> @{ ViewBag.Title = "用户组列表"; Layout = "~/Views/Layout/_Manage.cshtml"; } <div class="left"> <div class="top"></div> 左侧列表 </div> <div class="split"></div> <div class="workspace"> <div class="inside"> <div class="notebar"> <img alt="" src="~/Skins/Default/Manage/Images/UserGroup.gif" />用户组列表 </div> <div class="buttonbar">@Html.ActionLink("添加用户组", "Add", "UserGroup") 用户组类型: @Html.DropDownList("GroupTypeList") </div> <table> <tr> <th> @Html.DisplayNameFor(model => model.Name) </th> <th> @Html.DisplayNameFor(model => model.Type) </th> <th> @Html.DisplayNameFor(model => model.Description) </th> <th></th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Name) </td> <td> @Html.DisplayFor(modelItem => item.Type) </td> <td> @Html.DisplayFor(modelItem => item.Description) </td> <td> @Html.ActionLink("修改", "Edit", new { id = item.UserGroupId }) | <a href="javascript:void(0)" onclick="Delete(@item.UserGroupId,'@item.Name')" >删除</a> </td> </tr> } </table> </div> </div> <div class="clear"></div> <script type="text/javascript"> $("#GroupTypeList").change(function () { window.location.href = "/UserGroup/List/" + $(this).children("option:selected").val(); }) function Delete(id,name) { if (confirm("你确定要删除【" + name + "】吗?")) { $.post("@Url.Content("~/UserGroup/Delete")", {Id:id}, function (data) { if (data) { alert("删除【" + name + "】成功!"); location.reload(); } }); } } </script>
到此打完收工!
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持站长技术。
本文实例为大家分享了Ajax实现城市二级联动的具体代码,供大家参考,具体内容如...
概述 传统关系型数据库在诞生之时并未考虑到如今如火如荼的移动、社交以及大数据...
最近有一些关于AR的需求客户希望能在网页端或微信小程序端体验。 在网上搜索了一...
【51CTO.com快译】日益激烈的市场竞争和不断增长的客户期望促进企业业务的发展。...
但是我这个的特点是追究原理,我在乎的事情都想弄明白,于是各个qq群依次发信息...
正则表达式链接替换函数的技巧如下所示: 1) 字符串 前面的字符a href=" http://...
新建一般处理程序 public class Temp{ public int Index { get; set; } public s...
一个页面图片比较多的时候,需要对界面的图片进行懒加载处理,今天遇到了,做个...
前言 在实际的开发当中,相信很多的开发者在开发调试ASP.NET网站时候都是直接通...
本文匆匆已经全面测试,支持ASP+ACCESS以及ASP+SQL,请修改相关部分就可以了。 ...