Chapter 4 of the mvc44 website creation tutorial deletes section 4.4 and mvc44.4

Source: Internet
Author: User
Tags actionlink

Chapter 4 of the mvc44 website creation tutorial deletes section 4.4 and mvc44.4

Iii. Topic

3.1 Add a topic

3.2 browse topic

3.3 update topic

3.4 delete a topic

Open [CategoryController], add and delete the topic ManageDeleteJson (int id), and check whether a subtopic exists in action. If a subtopic exists, it cannot be deleted. If no subtopic exists, it is deleted.

/// <Summary> // delete a column (in Json format) /// </summary> /// <param name = "id"> </param> /// <returns> </returns> [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 the delete button after the modify button <input id = "btn_del" type = "button" value = "delete"/>

Add js script

$ ("# Btn_del"). click (function () {if (confirm ("are you sure you want to delete the change column? \ N if this topic has subtopics, please delete them first! ") {$. Post ("@ Url. action ("ManageDeleteJson", "Category") ", {id: $ (" # CategoryId "). val ()}, function (data) {if (data) {alert ("column deleted successfully! "); Top. location =" @ Url. Action ("Manage", "Category") ";} else {alert (" An error occurred while deleting the topic! If this topic has subtopics, delete them first. ");}});}});

Open your browser and test it.

Supplement:Other topic management issues

I. Topic Management Homepage Category/Manage

The Management Homepage is the default page for topic management. It is an empty page.

Open [CategoryController], add [Manage] acton, and copy a copy of ManageDetails. cshtml view, named Manage. cshtml, delete @ using (Html. in the BeginForm () Section, modify the Code as follows:

@ {ViewBag. Title = "topic management"; Layout = "~ /Views/Layout/_ Manage. cshtml ";}< div class =" workspace "> <div class =" inside "> <div class =" notebar ">  topic management </div> <div class =" left "> <div class =" top "> </div> @ Html. action ("ManagePartialTree", "Category") </div> <div class = "split"> </div> <div class = "clear"> </div>

The Code deletes the @ section Scripts code block at the bottom. This is because the menubutton of easyui is used in the top menu bar of the background management page. In this way, the reference of easyui is placed in layout page _ Manage. cshtml.

Open _ Manage. cshtml and add

@ Scripts. Render ("~ /Bundles/jquery ")
@ Scripts. Render ("~ /Bundles/EasyUi ")

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

On the _ Manage. cshtml layout page, <div class = "menubar"> ...... </Div> Add the code for column management.

<Div class = "menubar"> <ul> <li> @ Html. actionLink ("System Management", "dd", "dd") </li> <a href = "javascript: void (0) "class =" easyui-menubutton "data-options =" menu: '# menu_category' "> topic management </a> </li> </ul> <div id =" menu_category "class =" migroup "data-options =" iconCls: 'icon-add' "> <div> @ Html. actionLink ("Management Homepage", "Manage", "Category") </div> <div> @ Html. actionLink ("add topic", "ManageAdd", "Category") </div>

Check the effect in the browser.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.