@using System.Reflection @using Microsoft.AspNetCore.Mvc.Controllers @using Infrastructure.Web.Mvc @{ var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute()?.Scope; var controller = this.ViewContext.RouteData.Values["controller"].ToString(); var action = this.ViewContext.RouteData.Values["action"].ToString(); var url = HtmlAction ?? (ViewData.Keys.Any(o => o.ToLower() == "returnurl") ? Url.Action(null, null, new { ReturnUrl = ViewData["ReturnUrl"] }) : Url.Action(null, null)); var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit); }
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "错误:", new { @class = "text-danger col-sm-8" }, "div")
@foreach (var prop in props) { var metadata = prop as Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata; if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId") { @Html.Hidden(prop.PropertyName) continue; } if (prop.HideSurroundingHtml) { @Html.Hidden(prop.PropertyName) continue; } var uihit = prop.DataTypeName ?? prop.TemplateHint;
@Html.Label(prop.PropertyName, prop.GetDisplayName() + ":", new { @class = "col-sm-1 col-form-label", style = "text-align: right;" })
@if (metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(System.ComponentModel.ReadOnlyAttribute))) { @Html.Hidden(prop.PropertyName) @Html.Display(prop.PropertyName, uihit) } else { @Html.Editor(prop.PropertyName, uihit) } @Html.ValidationMessage(prop.PropertyName, new { @class = "text-danger" })
@{ if (metadata != null) { var attr = metadata.Attributes.Attributes.OfType().FirstOrDefault() as System.ComponentModel.DescriptionAttribute; if (attr != null && attr.Description != null) { @attr.Description } } }
}
@if (!DisableBackUrl && string.IsNullOrEmpty(BackUrl)) { BackUrl = Url.Action("Index", null); 返回 } @if (controller == "Account" && action == "Login") { 忘记密码? }