调用
Html.EditorFor(m => m)时,其中m是具有公共属性的公共类,将为具有[HiddenInput]属性的属性显示隐藏输入和标签.
>如何隐藏标签而不将其设为私有或创建编辑器模板?
例
public class User { [HiddenInput] public Guid ID { get; set; } // should not be displayed in editor template public string Name { get; set; } // should be editable }
带编号的EditorFor(…)对ID属性的不良结果
<div class="editor-label"> <label for="ID">ID</label> <!-- Why is this here? --> </div> <div class="editor-field"> <input id="ID" name="ID" type="hidden" value=""> </div>