JQuery UI datepicker in Asp.Net MVC

后端 未结 4 724
南笙
南笙 2020-12-30 05:49

I have tried to use some of the widgets in JQuery UI on an Asp.Net MVC site without luck.

For example the basic datepicker from jQuery UI -

4条回答
  •  隐瞒了意图╮
    2020-12-30 06:00

    Where in the page are you loading scripts & where are you calling the datepicker initialization?

    Here is a sample of using jQuery shorthand document ready & css selectors to initialize datePickers more easily.

    Here is the razor code for a sample input box (notice the "datefield" css class)

    @Html.LabelFor(m => m.DateOfBirth, new { @class = "col-md-2 control-label" })
    @Html.TextBoxFor(m => m.DateOfBirth, new { @class = "form-control datefield" })

    Here is the javascript needed to initialize any datepicker by css selector

    $(function () {
        $(".datefield").datepicker();
    });
    

    I've put together a tutorial detailing the specifics & a sample ASP.NET MVC5 solution on github

    http://prestoasp.net/using-the-jquery-datepicker-with-asp-net-mvc/ https://github.com/fredo007/i6technology/tree/master/InsuranceSales

提交回复
热议问题