在调用时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
}
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)