Hi
I have an ASP.NET MVC Page that i have to display the fields in customized Text. For that I have built a CustomModel RequestViewModel with the following fields.
Description, Event, UsageDate
Corresponding to these my custom Model has the below code. So that, the DisplayName is displayed on the ASP.NET MVC View page.
Now being the Description and Event string Datatype, both these fields are displaying Custom DisplayMessage. But I have problem with Date Datatype. Instead of "Date of Use of Slides", it is still displaying UsageDate from the actualModel.
Anybody faced this issue with DateDatatype?
Appreciate your responses.
Custom Model:
[Required(ErrorMessage="Please provide a description")]
[DisplayName("Detail Description")]
[StringLength(250, ErrorMessage = "Description cannot exceed 250 chars")]
// also need min length 30
public string Description { get; set; }
[Required(ErrorMessage="Please specify the name or location")]
[DisplayName("Name/Location of the Event")]
[StringLength(250, ErrorMessage = "Name/Location cannot exceed 250 chars")]
public string Event { get; set; }
[Required(ErrorMessage="Please specify a date", ErrorMessageResourceType = typeof(DateTime))]
[DisplayName("Date of Use of Slides")]
[DataType(DataType.Date)]
public string UsageDate { get; set; }
ViewCode:
<p>
<%= Html.LabelFor(model => model.Description) %>
<%= Html.TextBoxFor(model => model.Description) %>
<%= Html.ValidationMessageFor(model => model.Description) %>
</p>
<p>
<%= Html.LabelFor(model => model.Event) %>
<%= Html.TextBoxFor(model => model.Event) %>
<%= Html.ValidationMessageFor(model => model.Event) %>
</p>
<p>
<%= Html.LabelFor(model => model.UsageDate) %>
<%= Html.TextBoxFor(model => model.UsageDate) %>
<%= Html.ValidationMessageFor(model => model.UsageDate) %>
</p>