cagin
cagin

Reputation: 5930

How to use a simple calender in MVC 4 Razor

I am very new on MVC. How can I use a calender? Here is my div

   <div class="editor-field">
        @Html.EditorFor(model => model.CommunicationTime)
        @Html.ValidationMessageFor(model => model.CommunicationTime)
    </div>

But it shows only a text box. What should I do?

Upvotes: 2

Views: 2461

Answers (1)

Eiaddar
Eiaddar

Reputation: 180

try to add Data annotations DateType(DateType.Date) within your model here is a sample :

[Display(Name = "Date of Birthday")]

[DataType(DataType.Date)]

public DateTime DOB { get; set; }

this Should work in Chrome , Firefox , Safari or any browser Supports HTML5 that's because the produced html tags will contain type="Date" in date field

Upvotes: 1

Related Questions