1

i have the following view with textbox attached with jquery datepicker, this shows the text box with DOB button next to it with datetime format label but when click button or click on the textbox it does not show the datepicker. How do i fix this?

@model dtTest.OrderTime

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>OrderTime</legend>

        @Html.HiddenFor(model => model.id)

        <div class="editor-label">
            @Html.LabelFor(model => model.TimeZone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TimeZone)
            @Html.ValidationMessageFor(model => model.TimeZone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TimeUTC)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TimeUTC)
            @Html.ValidationMessageFor(model => model.TimeUTC)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {

    @Scripts.Render("~/bundles/jqueryval")

    <script>
        $('document').ready(function () {
            $('#TimeUTC').datepicker({
                appendText: 'mm/dd/yyyy',
                showOn: 'both',
                buttonText: 'DOB',
                dateFormat: 'dd/dd/yy',
                changeMonth: true,
                changeYear: true,
                minDate: new Date(2000, 0, 1),
                maxDate: new Date(2005, 0, 1)
            });
        });
    </script>
}

my layout file adds the jqueryui bundle

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    @RenderBody()

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")

    @RenderSection("scripts", required: false)
</body>
</html>

bundle files are:

    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                        "~/Scripts/jquery-ui-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.unobtrusive*",
                        "~/Scripts/jquery.validate*"));
}}

when i click the textbox the browser throws the following error in the console (chrome)

enter image description here

here is my scripts folder:

enter image description here

Phill Greggan
  • 2,234
  • 3
  • 20
  • 33

1 Answers1

1

In visual studio

Menu > TOOLS > Library and Package Manager > Package Manager Console

PM > Install-Package JQuery -Version Press Tab here to see all version here.

This update existing jQuery package and solve your problem with old jQuery version.

For more check How to get latest jQuery 1.x via Nuget in Visual Studio?

Community
  • 1
  • 1
Parth Trivedi
  • 3,802
  • 1
  • 20
  • 40