0

How do i add datepicker using bootstrapdatepicker in MVC application?

Am creating one application using .net MVC. I want to add datepicker. I downloaded bootstrapdatepicker using nu-get package. Could anyone please explain how to use it? I tried below but it doesn't work.

Addded js and css files

  1. datepicker3.css
  2. bootstrap-datepicker.js

Then i added one input box in my page Hide Copy Code

<input type="text" id="gd" type="text" class="form-control">

added below code as well Hide Copy Code

$(document).ready(function () {
  $("#gd").datepicker({
    calendarWeeks: true
  });
});

Please suggest if you have any other way to do this or explain me how to do this using nuget package? But nothing is coming when I click on input box . But am expecting datepicker to populate. What is the issue here?

3
  • Are you getting any errors in the browser console? Commented Apr 1, 2015 at 7:35
  • Are you including the bootstrap? Is the code in <script> tags? Commented Apr 1, 2015 at 7:36
  • jsfiddle.net/Lnj43bxL/1 Commented Apr 1, 2015 at 7:45

2 Answers 2

1

look for the tool button in toolbar, select nuget package manager , select package Manager Console, type in package Manager console "Install-Package datepicker

Sign up to request clarification or add additional context in comments.

Comments

0

You need to have

  1. jQuery 1.7.1+
  2. Bootstrap 2.0.4+
  3. datepicker.js
  4. datepicker.css

for making Datepicker to work. The reason it is not working for you might be because you installed the datepicker from NuGet package, but the downloaded files are not included in the files in which you want datepicker. Please make sure all the files below are included in the order they are. It should work.

<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"></script>
<script src="~/Scripts/bootstrap-datepicker.min.js"></script>
<link href="~/Content/bootstrap-datepicker.min.css" rel="stylesheet" />

Here's the code that worked for me. enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.