How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine?

后端 未结 9 881
执念已碎
执念已碎 2020-11-28 20:13

I need some guide lines on how to install a Date Picker Bootstrap 3 on a MVC 5 project using the Razor engine. I found this link here but couldn\'t make it work in VS2013. <

9条回答
  •  情歌与酒
    2020-11-28 20:22

    This answer uses the jQuery UI Datepicker, which is a separate include. There are other ways to do this without including jQuery UI.

    First, you simply need to add the datepicker class to the textbox, in addition to form-control:

    @Html.LabelFor(model => model.DropOffDate) @Html.TextBoxFor(model => model.DropOffDate, new { @class = "form-control datepicker", placeholder = "Enter Drop-off date here..." }) @Html.ValidationMessageFor(model => model.DropOffDate)

    Then, to be sure the javascript is triggered after the textbox is rendered, you have to put the datepicker call in the jQuery ready function:

    
    

提交回复
热议问题