yra*_*man 5 .net c# asp.net-mvc asp.net-mvc-5
我正在尝试在部分视图中为枚举模型呈现隐藏字段
我的代码是
@model App.PrivacyLevelEnum
@Html.HiddenFor(m=>m);
Run Code Online (Sandbox Code Playgroud)
我已经检查过模型不为空,但在渲染视图时出现以下错误
值不能为 null 或为空。\r\n参数名称: name 堆栈跟踪 在 System.Web.Mvc.Html.InputExtensions.InputHelper(HtmlHelper htmlHelper, InputType inputType, ModelMetadata 元数据, 字符串名称, 对象值, Boolean useViewData, Boolean isChecked, Boolean setId, Boolean isExplicitValue, String format, IDictionary`2 htmlAttributes) 在 System.Web.Mvc.Html.InputExtensions.HiddenHelper(HtmlHelper htmlHelper, ModelMetadata metadata, Object value, Boolean useViewData, String expression, IDictionary`2 htmlAttributes) 在 System.Web.Mvc.Html.InputExtensions.HiddenFor[TModel,TProperty](HtmlHelper`1 htmlHelper, Expression`1 表达式, IDictionary`2 htmlAttributes) 在 System.Web.Mvc.Html.InputExtensions.HiddenFor[TModel,TProperty](HtmlHelper`1 htmlHelper, Expression`1 表达式) 在 ASP._Page_Views_Profile_PrivacyLevel_cshtml.Execute() in c:\TFS\DEFAULTCOLLECTION\Gac.Hr\Development\Source\Gac.Hr.Web.Html5\Views\Profile\PrivacyLevel.cshtml:line 58 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 在 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) 在 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) 在 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) 在 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) 在 System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) 在 ASP._Page_Views_Profile_ProfileDetailsEditor_cshtml.Execute() in c:\TFS\DEFAULTCOLLECTION\Gac.Hr\Development\Source\Gac.Hr.Web.Html5\Views\Profile\ProfileDetailsEditor.cshtml:line 107 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 在 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) 在 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) 在 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) 在 GacHrUI.Controllers.ProfileController.StringifyView(String viewName, Object model) in c:\TFS\DEFAULTCOLLECTION\Gac.Hr\Development\Source\Gac.Hr.Web.Html5\Controllers\ProfileController.cs:line 62 在 GacHrUI.Controllers.ProfileController.RenderEditMode() in c:\TFS\DEFAULTCOLLECTION\Gac.Hr\Development\Source\Gac.Hr.Web.Html5\Controllers\ProfileController.cs:line 35 在 lambda_method(Closure , ControllerBase , Object[] ) 在 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase 控制器,Object[] 参数) 在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 参数) 在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 参数) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() 在 System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object 标签) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.c__DisplayClass46.b__3f()
快速帮助将不胜感激
| 归档时间: |
|
| 查看次数: |
2046 次 |
| 最近记录: |