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

后端 未结 9 879
执念已碎
执念已碎 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:13

    This answer simply applies the type=date attribute to the HTML input element and relies on the browser to supply a date picker. Note that even in 2017, not all browsers provide their own date picker, so you may want to provide a fall back.

    All you have to do is add attributes to the property in the view model. Example for variable Ldate:

    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
    Public DateTime Ldate {get;set;}
    

    Assuming you're using MVC 5 and Visual Studio 2013.

提交回复
热议问题