When calling Html.EditorFor(m => m)
, where m
is a public class with public properties, a hidden input and a label are displayed for properties with the [HiddenInput]
attribute.
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(...)
with label<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>
[HiddenInput(DisplayValue=false)]
Otherwise HideSurroundingHtml
is not set correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With