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 develop and delete in MVC4 production website

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

Share

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

MVC4 production site how to delete the column, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

I. column

1.1 add columns

1.2 browse the column

1.3 Update column

1.4 Delete columns

Open [CategoryController] first, add the delete column ManageDeleteJson (int id), and check whether there is a sub-column in action. If you have a sub-column, you cannot delete it. If there is no sub-column, delete it.

/ [AdminAuthorize] public JsonResult ManageDeleteJson (int id) {categoryRsy = new CategoryRepository (); if (categoryRsy.Children (id). Count () > 0) return Json (false); return Json (categoryRsy.Delete (id));}

Open ManageDetails.cshtml

Add a delete button after the modify button

Add js script

("# btn_del") .click (function () {if (confirm ("are you sure you want to delete the changed column?\ nPlease delete the subcolumn first if there is a subcolumn in this column!")) {$.post ("@ Url.Action (" ManageDeleteJson "," Category ")", {id: $("# CategoryId") .val ()}, function (data) {if (data) {alert ("column deleted successfully!") ; top.location = "@ Url.Action (" Manage "," Category ")";} else {alert ("failed to delete the column! please delete the subcolumn first if there is a subcolumn in the column.") ;}})

Open a browser to test it.

Add: some other matters of column management

First, column management home page Category/Manage

The management home page is the default page for column management and is temporarily an empty page.

Open [CategoryController], add [Manage] acton, make a copy of the ManageDetails.cshtml view, name it Manage.cshtml, delete the @ using (Html.BeginForm ()) section, and change the code as follows:

@ {ViewBag.Title = "column Management"; Layout = "~ / Views/Layout/_Manage.cshtml";}

Column management @ Html.Action ("ManagePartialTree", "Category")

The code deletes the bottom @ section Scripts code block because the background manages the menu bar at the top of the page and uses easyui's menubutton, so put a reference to easyui in the layout page _ Manage.cshtml.

Open _ Manage.cshtml and add to it

@ Scripts.Render ("~ / bundles/jquery")

@ Scripts.Render ("~ / bundles/EasyUi")

Delete these two sentences at the bottom of the two views of ManageAdd.cshtml,ManageDetails.cshtml

In the _ Manage.cshtml layout page... Add the code for column management in, and what it will look like when it is finished

@ Html.ActionLink ("system Administration", "dd", "dd") column Management @ Html.ActionLink ("manage Home", "Manage", "Category") @ Html.ActionLink ("add columns", "ManageAdd", "Category")

Take a look at the browser.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow 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.

Share To

Development

Wechat

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

12
Report