Tuesday, February 25, 2014

JQuery UI Datepicker Popup Calendar with ASP.NET MVC 5

JQuery UI Datepicker in ASP.NET MVC 5 STEP BY STEP


Tools > Library Package Manager>Package Manager Console

PM> Install-Package jQueryUIHelpers.Mvc5 

  Concentrate on the Images carefully(double Click) for JQuery Datepicker in asp.net MVC 5:


In the BundleConfig file create a new bundle((for the jquery-ui.unobtrusive-x.y.z.js). It is also possible to add this to the jQuery UI bundle so it will always be included when jQuery UI is referenced. The following example demonstrates this.)

bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(

Make sure there is also a bundle with the required jQuery UI CSS files. The example below shows how to create one that uses only the JQuery UI datepicker, but all other CSS files can be included in the list.

bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(

Render the bundles on the layout page or the views that need them. Add the jQuery UI CSS files like so (you also have to define the bundle in BundleConfig):
And the JavaScript files
If you use client side validation include the validation scripts before the jQuery UI Helpers script      


The library adds a single extension method JQueryUI<TModel>()which serves as the entry point of the library

The jQuery UI Helpers entry point.


For example  a simple JQuery Datepicker can be like this:

                <label for="date">Select a date:</label>

Detail example of a JQuery UI Datepicker in asp.net mvc5:


    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
    [DisplayName("Due Date")]
    public DateTime? InsDueDate { get; set; }

View > Create >create.cshtml

 <div class="form-group">
@Html.LabelFor(model => model.InsDueDate, new{@class = "control-label col-md-2"})

     <div class="col-md-10">

                    <label for="Install Due Date"></label>
                     @Html.JQueryUI().DatepickerFor(model => model.InsDueDate)
                     @Html.ValidationMessageFor(model => model.InsDueDate)


To Get:

FOR More Than One Month

The jQuery UI widgets have many options to customize their behaviour. The jQuery UI Helpers library supports this with a fluent configuration API.
Another JQuery UI Datepicker in asp.net MVC 5 can be created like the below:

<label for="anotherDate">Select another date: </label>

Getting Started with Entity Framework 6 Using MVC 5