Quickly build an edit type pop-up window

Source: Internet
Author: User

The first step: Define the Entity class, or define ViewModel (need to inherit Baseviewmodel), the sample code is as follows:

   /// <summary>    ///links/// </summary>     Public classLink:baseviewmodel, IWidget {/// <summary>        ///Link Name/// </summary>[Display (Name="Link Name")] [Field (Listshow=true, editshow =true, Controlstype =Controlstype.textbox)] [Required (ErrorMessage="link name cannot be empty")] [Stringlength ( -, errormessage ="Link name cannot manipulate 20 characters")]         Public stringName {Get;Set; } /// <summary>        ///Link URL/// </summary>[Display (Name ="URL")] [Field (Listshow=true, editshow =true, Controlstype =Controlstype.textbox)] [Required (ErrorMessage="the link cannot be empty")]         Public stringURL {Get;Set; } /// <summary>        ///icons/// </summary>[Display (Name ="icons")] [Field (Listshow=false, editshow =true, Controlstype =Controlstype.textbox)] Public stringIcon {Get;Set; } /// <summary>        ///Open Mode/// </summary>[Display (Name ="Open Mode")] [Field (Listshow=true, editshow =true, Controlstype = controlstype.dropdownlist, DataSource ="ZKCloud.Core.Theme.Domain.Enums.Target")]         PublicTarget Target {Get;Set; } /// <summary>        ///Link Font Color/// </summary>[Display (Name ="Color")] [Field (Listshow=false, editshow =true, Controlstype =Controlstype.color)] Public stringColor {Get;Set; } ="#666666"; /// <summary>        ///Link title/// </summary>[Display (Name ="Link title")] [Field (Listshow=false, editshow =true, Controlstype =Controlstype.textbox)] Public stringTitle {Get;Set; } /// <summary>        ///Sort/// </summary>[Field (Listshow =true, editshow =true, Controlstype =Controlstype.textbox)] [Display (Name="Sort")]         Public LongSortOrder {Get;Set; } = +; /// <summary>        ///is displayed/// </summary>[Field (Listshow =true, Controlstype =Controlstype.switch)] [Display (Name="is displayed")]         Public BOOLIsshow {Get;Set; } =true; /// <summary>        ///Edit and display with/// </summary>[Field (Editshow =false)]         PublicGUID GUID {Get;Set; } =Guid.NewGuid (); }
View Code

Step Two: Specify the view in the controller: ~/admin/core/common/dialog.cshtml needs to give viewdata["type"]

   Public Iactionresult Addlink (stringstringnull) {         = resolve<ilinkservice> (). GetLink (type, GUID);         viewdata["type"] = type;          = Type.GetType (Type);         return View ("~/admin/core/common/dialog.cshtml", link);}

Step three: Define pop-ups using Dialog-url taghelper in the view

<a dialog-url="/admin/diy/addlink?type=userleftnav " dialog-title= " Article add " dailog-size="size-fullscreen">    class= "  "></i> article add </a>

Dialog-url: Specify the URL of the access
Dialog-title: dialog box title
dailog-size: Window Size ( size-fullscreen, Wide,nomal)

View



Application Range:
Batch modification, add shipping address, admin change price, List page data operation
Implementation principle:
    @Html. Hidden ("type", viewdata["type"])    @await Html.adminwidget ("Core""Common/adminautoconfig_control ")

~/admin/core/common/dialog.cshtml Code

@{Layout="~/admin/open/_openlayout.cshtml";}<divclass="Portlet"> <divclass="Portlet-body"> <form method="Post" class="form-horizontal form-row-seperated"Asp-controller="Adminwidget"asp-action="Addlink"> <divclass="Form-body"> <divclass="Form-group-error"> <divclass="col-md-offset-2 col-md-10"> <div asp-validation-summary=" All" class="Text-danger"></div> </div> </div>@Html. Hidden ("type", viewdata["Type"]) @await Html.adminwidget ("Core","Common/adminautoconfig_control")                <divclass="Form-group"> <labelclass="Control-label col-md-2"> </label> <divclass="col-md-4"> <button type="Submit" class="btn Btn-transparent Green Active"> Save </button> </div> </div> </div> </form > </div></div>
View Code

Quickly build an edit type pop-up window

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.