In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
MVC4 production website how to develop user group operation, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can harvest.
I. Users
II. User Groups
2.1 to post within this
2.2 add user group
Edit [Add]Action
/// ///add user group /// /// [AdminAuthorize] public ActionResult Add() { ViewData.Add("Type", TypeSelectList); return View(); }
Add Strongly Typed Views
After completion, the code is as follows:
@model Ninesky.Models.UserGroup@{ ViewBag.Title = "Add User Group"; Layout = "~/Views/Layout/_Manage.cshtml";} Left List
add user group @using (Html.BeginForm()) { @Html.ValidationSummary(true) user group data @Html.HiddenFor(model => model.UserGroupId) @Html.LabelFor(model => model.Type) @Html.DropDownList("Type") @Html.LabelFor(model => model.Name) @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) @Html.LabelFor(model => model.Description) @Html.EditorFor(model => model.Description) @Html.ValidationMessageFor(model => model.Description) } @section Scripts { @Scripts.Render("~/bundles/jqueryval")}
Modify User Group Add Action [Add(UserGroup userGroup)]Action, code after completion
[HttpPost] [AdminAuthorize] public ActionResult Add(UserGroup userGroup) { userGroupRsy = new UserGroupRepository(); if (userGroupRsy.Add(userGroup)) { Notice _n = new Notice { Title = "Add User Group Successfully", Details = "You have successfully added ["+userGroup.Name+"] User Group! ", DwellTime = 5, NavigationName = " User Group List ", NavigationUrl = Url.Action("List", "UserGroup") }; return RedirectToAction("ManageNotice", "Prompt", _n); } else { Error _e = new Error { Title = "Failed to add user group", Details = "Failed to save to database when adding user group", Cause = "System error", Solution = Server.UrlEncode("Return to add user page, enter correct information and try again to contact website administrator") }; return RedirectToAction("ManageError", "Prompt", _e); } }
Check it in your browser.
Enter information to test it, you can add information.
Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.