MVC - How To Add Date Picker Bootstrap 3 On MVC 5 Project Using The Razor Engine - Stack Overflow
MVC - How To Add Date Picker Bootstrap 3 On MVC 5 Project Using The Razor Engine - Stack Overflow
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/bootstrap-datepicker.js", // ** NEW for Bootstrap
Datepicker
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-datepicker.css", // ** NEW for Bootstrap
Datepicker
"~/Content/site.css"));
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$('.datepicker').datepicker(); //Initialise any date pickers
</script>
}
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service. edited Dec 11 '14 at 5:55
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 1/9
29/5/2019 asp.net mvc - How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine? - Stack Overflow
Dhaust
4,116 7 47 69
9 Answers
<script type="text/javascript">
$(function () { // will trigger w
$('.datepicker').datepicker();
});
</script>
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0
Public DateTime Ldate {get;set;}
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 3/9
29/5/2019 asp.net mvc - How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine? - Stack Overflow
if (!Modernizr.inputtypes.date) {
$(function () {
$(".datecontrol").datepicker()
});
By using our site,}you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 4/9
29/5/2019 asp.net mvc - How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine? - Stack Overflow
bundles.Add(New ScriptBundle("~/bundl
"~/Scripts/bootstrap.js
"~/Scripts/bootstrap-da
"~/Scripts/DatePickerRe
"~/Scripts/respond.js")
bundles.Add(New StyleBundle("~/Conten
"~/Content/bootstrap.cs
"~/Content/bootstrap-da
"~/Content/site.css"))
<Required>
<DataType(DataType.Date)>
Public Property DOB As DateTime? = No
@Html.EditorFor(Function(model) model
= "form-control datecontrol", .PlaceH
and voila
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 5/9
29/5/2019 asp.net mvc - How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine? - Stack Overflow
In AppStart/BundleConfig.cs, add
the related scripts and styles in
the bundles.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service. bundles.Add(new ScriptBundle("~/b
//...,
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 6/9
29/5/2019 asp.net mvc - How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine? - Stack Overflow
"~/Scripts/bootstrap-datepi
"~/Scripts/locales/bootstra
bundles.Add(new StyleBundle("~/Co
...,
"~/Content/bootstrap-datepi
@section scripts{
<script type="text/javascript
//...
$('.datepicker').datepick
format: 'dd/mm/yyyy',
language: "YOUR-LOCAL
orientation: 'left bo
});
</script>
@Html.TextBox("YOUR-STRING-FOR-TH
})
[DataType(DataType.Date)]
public DateTime BirthDate { get; set;
4
decorate your model like this. can use
a bootstrap date time picker I used
this one.
https://github.com/Eonasdan/bootstra
p-datetimepicker/
Your
By using our site, you date picker bundle
acknowledge that youentries
have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 7/9
29/5/2019 asp.net mvc - How to add Date Picker Bootstrap 3 on MVC 5 project using the Razor engine? - Stack Overflow
bundles.Add(new ScriptBundle("~/bund
"~/Scripts/moment.min.js",
"~/Scripts/bootstrap-datet
bundles.Add(new StyleBundle("
"~/Content/bootstrap
@Styles.Render("~/Content/datepicker"
@Scripts.Render("~/bundles/datePicker
<div class="form-group">
@Html.LabelFor(model => model
col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model =>
form-control" })
@Html.ValidationMessageFo
"text-danger" })
</div>
</div>
<script>
$(document).ready(function () {
$('.datetimepicker').datetime
format: 'lll'
});
});
</script>
@(Html.ShieldDatePicker()
.Name("datepicker"))
Simple:
-2 [DataType(DataType.Date)]
Public DateTime Ldate {get;set;}
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.
https://stackoverflow.com/questions/21104633/how-to-add-date-picker-bootstrap-3-on-mvc-5-project-using-the-razor-engine 9/9