I am using Model binding with the Entity Framework and have an Html.TextBoxFor(model =>model.date) input. I know how to tell jQuery how to implement a datepicker but not in this context. What would I need to add here to have a calendar popup when the user enters this field?
I am using Model binding with the Entity Framework and have an Html.TextBoxFor(model =>model.date)
Share
You’ll want to use the HtmlHelper overload that allows you to specify Html attributes. Then target them with the jquery selector.
Though I recommend using
EditorForinstead.You can create an EditorTemplate to handle any field that is a
DateTimeand have it output the proper field.Create
/Views/Shared/EditorTemplates/DateTime.ascxand put this in it…Or if you need to allow DateTime’s with nulls:
Then you can always use EditorFor and have a central ascx to edit if you ever want to modify the way date times are handled in your views.