Having the following view model in my ASP.NET MVC 3 application, I have a problem described below:
public class MyViewModel : ViewModelBase
{
// having this line kills the one below it, while commenting it out solves the problem. WHY?
[DataType(DataType.Text)]
[Display(Name = "Name", Description = "Description", Prompt = "Prompt"]
public new string MyField { get; set; }
}
As soon as I comment out [DataType(DataType.Text)] I can see all other things appear, but if used together, DataType.Text is kind of overriding one below it (at least it seems like it).
Why is this happening and how to workaround?
Thanks in advance.
Oh, just figured it out. In case somebody needs it:
I have editor template that is under
Shared/EditorTemplates/String.cshtmlthat does all the magic withDisplayAttribute, while[DataType(DataType.Text)]is actually redirecting string to be text and I need to create yet another EditorTemplate parallel toString.cshtlcalledText.cshtml.Live and Learn!