Friday, 12 February 2016

MVC - How to add Calendar extension to textBox

Watch this example on YouTUbe:



1. Ensure Layout.cshtml has the following at the beginning:
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
        @Scripts.Render("~/Scripts/jquery-1.8.2.min.js")
    </head>

and the following at the end:
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/jqueryui")
        @Styles.Render("~/Content/themes/base/css", "~/Content/css")
        @Scripts.Render("~/Scripts/DatePicker.js")          
        @RenderSection("scripts", required: false)
    </body>

2. Create DatePicker.js in scripts folder:
$(function () {
    $('.editor-file-date').datepicker();
});

3. Now every control with with class editor-file-date will have calendar extension

No comments:

Post a Comment