Hide editor label for public property when calling editor (...)?

When calling Html.EditorFor(m => m) , where m is a public class with public properties, hidden properties and label attributes are displayed for properties with [HiddenInput] properties.

  • How to hide a shortcut without making it closed or creating an editor template?

Example

 public class User { [HiddenInput] public Guid ID { get; set; } // should not be displayed in editor template public string Name { get; set; } // should be editable } 

Undesired result for ID property using EditorFor(...) tagged

 <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> 
+6
asp.net-mvc-2 editorformodel
source share
1 answer

Solved by

 [HiddenInput(DisplayValue=false)] 

Otherwise, HideSurroundingHtml set incorrectly.

+10
source share

All Articles