我的MVC4应用程序中有以下代码行,它是从MVC3转换而来的:
@Html.HiddenFor(model => model.IsInhouse) // IsInhoue is bool当应用程序是MVC3时,它工作得很好,但现在它发生了故障。
我尝试使用@Html.LabelFor(model => model.IsInhouse)显示值,它显示为'IsInhouse',而不是内容值。
关于这个问题的任何线索都是有价值的。我是MVC的新手。
编辑:用<input type="hidden" name="IsInhouse" value="@Html.AttributeEncode(Model.IsInhouse)" id="IsInhouse" />替换@Html.HiddenFor解决了这个问题。
发布于 2013-11-04 13:49:53
LabelFor会显示它的属性名,这就是它的目的。要获取它的值,请使用EditorFor
https://stackoverflow.com/questions/19762103
复制相似问题