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

MVC4制作網(wǎng)站教程第三章 添加用戶組操作3.2

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

一、用戶

二、用戶組

2.1瀏覽用戶組

2.2添加用戶組

修改[Add]Action

/// summary>
    /// 添加用戶組
    /// /summary>
    /// returns>/returns>
    [AdminAuthorize]
    public ActionResult Add()
    {
      ViewData.Add("Type", TypeSelectList);
      return View();
    }

添加強(qiáng)類型視圖

完成后代碼如下:

@model Ninesky.Models.UserGroup@{
 ViewBag.Title = "添加用戶組";
 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" />添加用戶組
  /div>
  @using (Html.BeginForm())
  {
   @Html.ValidationSummary(true)
   fieldset>
    legend>用戶組資料/legend>

    @Html.HiddenFor(model => model.UserGroupId)
    ul>
     li>
      div class="editor-label">
       @Html.LabelFor(model => model.Type)
      /div>
      div class="editor-field">
       @Html.DropDownList("Type")
      /div>
     /li>
     li>
      div class="editor-label">
       @Html.LabelFor(model => model.Name)
      /div>
      div class="editor-field">
       @Html.EditorFor(model => model.Name)
       @Html.ValidationMessageFor(model => model.Name)
      /div>
     /li>
     li>
      div class="editor-label">
       @Html.LabelFor(model => model.Description)
      /div>
      div class="editor-field">
       @Html.EditorFor(model => model.Description)
       @Html.ValidationMessageFor(model => model.Description)
      /div>
     /li>
     li>
      div class="editor-label">
      /div>
      div class="editor-field">
       input type="submit" value="保存" />
      /div>
     /li>
    /ul>
   /fieldset>
  }
 /div>
/div>
div class="clear">/div>
@section Scripts {
 @Scripts.Render("~/bundles/jqueryval")
}

修改用戶組添加處理動(dòng)作[Add(UserGroup userGroup)]Action,完成后的代碼

[HttpPost]
  [AdminAuthorize]
  public ActionResult Add(UserGroup userGroup)
  {
   userGroupRsy = new UserGroupRepository();
   if (userGroupRsy.Add(userGroup))
   {
    Notice _n = new Notice { Title = "添加用戶組成功", Details = "您已經(jīng)成功添加["+userGroup.Name+"]用戶組!", DwellTime = 5, NavigationName = "用戶組列表", NavigationUrl = Url.Action("List", "UserGroup") };
    return RedirectToAction("ManageNotice", "Prompt", _n);
   }
   else
   {
    Error _e = new Error { Title = "添加用戶組失敗", Details = "在添加用戶組時(shí),未能保存到數(shù)據(jù)庫(kù)", Cause = "系統(tǒng)錯(cuò)誤", Solution = Server.UrlEncode("li>返回a href='" + Url.Action("Add", "UserGroup") + "'>添加用戶/a>頁(yè)面,輸入正確的信息后重新操作/li>li>聯(lián)系網(wǎng)站管理員/li>") };
    return RedirectToAction("ManageError", "Prompt", _e);
   }
  }

瀏覽器中查看一下

輸入資料測(cè)試一下,可以添加資料。

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

您可能感興趣的文章:
  • ASP.NET MVC5網(wǎng)站開發(fā)管理列表、回復(fù)及刪除(十三)
  • ASP.NET MVC5網(wǎng)站開發(fā)我的咨詢列表及添加咨詢(十二)
  • ASP.NET MVC5網(wǎng)站開發(fā)修改及刪除文章(十)
  • ASP.NET MVC5網(wǎng)站開發(fā)顯示文章列表(九)
  • ASP.NET MVC5網(wǎng)站開發(fā)添加文章(八)
  • ASP.NET MVC5網(wǎng)站開發(fā)文章管理架構(gòu)(七)
  • ASP.NET MVC5網(wǎng)站開發(fā)用戶修改資料和密碼(六)
  • ASP.NET MVC5網(wǎng)站開發(fā)用戶登錄、注銷(五)
  • ASP.NET MVC5 網(wǎng)站開發(fā)框架模型、數(shù)據(jù)存儲(chǔ)、業(yè)務(wù)邏輯(三)
  • ASP.NET MVC5網(wǎng)站開發(fā)項(xiàng)目框架(二)

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

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MVC4制作網(wǎng)站教程第三章 添加用戶組操作3.2》,本文關(guān)鍵詞  MVC4,制作,網(wǎng)站,教程,第三章,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quá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)站教程第三章 添加用戶組操作3.2》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于MVC4制作網(wǎng)站教程第三章 添加用戶組操作3.2的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章