濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > MVC4制作網(wǎng)站教程第三章 刪除用戶(hù)組操作3.4

MVC4制作網(wǎng)站教程第三章 刪除用戶(hù)組操作3.4

熱門(mén)標(biāo)簽:地圖標(biāo)注位置怎么弄圖 威力最大的電銷(xiāo)機(jī)器人 旅游地圖標(biāo)注線(xiàn)路 400電話(huà)唐山辦理 電銷(xiāo)專(zhuān)用外呼線(xiàn)路 漯河外呼調(diào)研線(xiàn)路 電話(huà)機(jī)器人鑰匙扣 廣西房產(chǎn)智能外呼系統(tǒng)推薦 電銷(xiāo)外呼系統(tǒng)是違法的嗎

一、用戶(hù)
二、用戶(hù)組

2.1瀏覽用戶(hù)組 
2.2添加用戶(hù)組 
2.3修改用戶(hù)組 
2.4刪除用戶(hù)組 

刪除用戶(hù)組相對(duì)簡(jiǎn)單些,不用單獨(dú)的頁(yè)面,直接在瀏覽頁(yè)面點(diǎn)擊刪除時(shí),彈出確認(rèn)刪除對(duì)話(huà)框,點(diǎn)擊確認(rèn),用jquery post刪除。 

打開(kāi)【UserGroupController】,刪掉public ActionResult Delele(int GroupId) { return View(); } 

修改刪除處理Action[Delete(int Id)],修改后的代碼 

/// summary>
 /// 刪除用戶(hù)組
 /// /summary>
 /// param name="Id">用戶(hù)組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);
 } 

這里返回類(lèi)型為JsonResult目的方便使用jquery 的post方式刪除。 

打開(kāi)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("你確定要?jiǎng)h除【" + name + "】嗎?")) {
 $.post("@Url.Content("~/UserGroup/Delete")", {Id:id}, function (data) {
 if (data) {
 alert("刪除【" + name + "】成功!");
 location.reload();
 }
 });
 }
 } 

完成后整個(gè)List.cshtml的代碼如下: 

@model IEnumerableNinesky.Models.UserGroup>

@{
 ViewBag.Title = "用戶(hù)組列表";
 Layout = "~/Views/Layout/_Manage.cshtml";
}
div class="left">
 div class="top">/div>
 左側(cè)列表
/div>
div class="split">/div>
div class="workspace">
 div class="inside">
 div class="notebar">
 img alt="" src="~/Skins/Default/Manage/Images/UserGroup.gif" />用戶(hù)組列表
 /div>
 div class="buttonbar">@Html.ActionLink("添加用戶(hù)組", "Add", "UserGroup") 用戶(hù)組類(lèi)型:
 @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("你確定要?jiǎng)h除【" + name + "】嗎?")) {
 $.post("@Url.Content("~/UserGroup/Delete")", {Id:id}, function (data) {
 if (data) {
 alert("刪除【" + name + "】成功!");
 location.reload();
 }
 });
 }
 }
/script> 

到此打完收工! 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)管理列表、回復(fù)及刪除(十三)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)我的咨詢(xún)列表及添加咨詢(xún)(十二)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)修改及刪除文章(十)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)添加文章(八)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)文章管理架構(gòu)(七)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶(hù)修改資料和密碼(六)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶(hù)登錄、注銷(xiāo)(五)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶(hù)注冊(cè)(四)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)項(xiàng)目框架(二)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)概述(一)

標(biāo)簽:綏化 試駕邀約 湘西 欽州 焦作 銅陵 無(wú)錫 湖北

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MVC4制作網(wǎng)站教程第三章 刪除用戶(hù)組操作3.4》,本文關(guān)鍵詞  MVC4,制作,網(wǎng)站,教程,第三章,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《MVC4制作網(wǎng)站教程第三章 刪除用戶(hù)組操作3.4》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于MVC4制作網(wǎng)站教程第三章 刪除用戶(hù)組操作3.4的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    巍山| 巨野县| 乡城县| 岫岩| 邵武市| 沅陵县| 墨脱县| 汤原县| 南和县| 泗阳县| 阿鲁科尔沁旗| 巢湖市| 留坝县| 稻城县| 林州市| 香港 | 嫩江县| 仁寿县| 隆回县| 雅江县| 赤峰市| 自治县| 白玉县| 灵丘县| 平远县| 方正县| 合肥市| 诸城市| 阿图什市| 临朐县| 江西省| 南皮县| 静乐县| 河间市| 翁牛特旗| 绩溪县| 驻马店市| 华池县| 南通市| 桦川县| 邹城市|