c# - asp.net mvc 5 template for collection of properties -
I want to group some controls of a model with a template (can not be hardcoded in C #) . If there are some changes on the layout, I can edit the template's html instead of converting it to each view.
It is what I have done so far:
View
& lt; Section square = "pure-living" & gt; @foreach (kwwalpere & lt; string, object & gt; item view) {if (vedata.model metadata properties) any (x = & gt; x property name == item.key)) {& lt; Div class = "pure-u-1 -2" & gt; @html Label (item) @html Editor (item) @html Validity message (item) & lt; / Div & gt; }} & Lt; / Section & gt;
And I am using this template:
@ Html.EditorFor (model = & gt; model, "InputBlock", new {model} First name, Model.LastName, Model.LastLogin, Model.Id}}
This works, it underlines all the controls because they should be with the right type.
The problem is that any features added in a model such as [urgent] or [DisplayName] are ignored, so label it Instead of displaying the property name, the value is set as DisplayName, even if the properties in the ModelMetadata are set correctly DisplayName.
Server-side verification works the same. [Required] or [String Lamp] is defined, only the default set type for people of the specific type (such as datetime or int) < / Em>
Comments
Post a Comment