Without using “UIHint” how to create .cshtml for certain types of data.
Examples
These are already working!
[DataType(DataType.Url)]
public string Link { get; set; }
will be used
Url.cshtml
[DataType(DataType.MultilineText)]
public string Descrition { get; set; }
will be used
MultilineText.cshtml
These, I am in doubt about how
public IEnumerable<SelectListItem> TypesList { get; set; }
will be used
???????????.cshtml
public DateTime? DateUpdated { get; set; }
will be used
???????????.cshtml
public int? Order { get; set; }
will be used
???????????.cshtml
Questions
In short, do not want to be putting in my ViewModel attributes, like that would work exactly like “Url” and “Multiline”
What should be the file name .cshtml that will be used to int?, IEnumerable<xx> or IEnumerable<string>
Remembering that you can not create files with "<", ">" or "?"
By convention (if you don’t specify any template name):
public IEnumerable<SelectListItem> TypesList { get; set; }will useSelectListItem.cshtml(not that since you have anIEnumerable<T>the editor template will be rendered for each element of the collection and will be calledT.cshtml)public DateTime? DateUpdated { get; set; }will useDateTime.cshtmlpublic int? Order { get; set; }will useInt32.cshtml…
You could also specify a template name in the view:
Assuming
TypesListis anIEnumerable<T>thenMyTemplate.cshtmlwill be strongly typed toIEnumerable<T>and not toT.