Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete user groups in MVC4 production website

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

本篇文章给大家分享的是有关MVC4制作网站中如何删除用户组操作,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

一、用户

二、用户组

2.1浏览用户组

2.2添加用户组

2.3修改用户组

2.4删除用户组

删除用户组相对简单些,不用单独的页面,直接在浏览页面点击删除时,弹出确认删除对话框,点击确认,用jquery post删除。

打开【UserGroupController】,删掉public ActionResult Delele(int GroupId) { return View(); }

修改删除处理Action[Delete(int Id)],修改后的代码

/// /// 删除用户组 /// /// 用户组Id /// [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 }) 改为删除 } $("#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(); } }); } }

到此打完收工!

以上就是MVC4制作网站中如何删除用户组操作,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report