Prakash Prakash - 1 year ago 120
jQuery Question

DateTimePicker is not showing

I am facing an issue with the datetime picker in jquery in MVC4. Here is my code:


$(function () {

But the datetime picker is not showing and showing an error

Uncaught TypeError: Cannot read property 'inline' of undefined"

In my model
is a nullable field. I want to give a default value to it.

Please help.

Answer Source

The first thing I notice in the script you posted is that your $(function () { is missing a closing ); at the end.

Also make sure you have properly included the jQuery and jQuery UI scripts in your page. If you are using bundles you might need to have the following scripts before the script that is attaching the date picker:


Normally the ~/bundles/jquery bundle is already included in the _Layout.cshtml if you used the Internet Application Template to create your project.

Another thing you should verify is that you do not have multiple fields with the same id. Also if this @Html.TextBox is inside an editor template the id might not be #RELIEVING_DATE but prefixed with the navigational property, for example #SomeProperty_RELIEVING_DATE. Look at the generated HTML in the browser to see the exact id. You could also assign a class to the field:

@Html.TextBoxFor(x => x.RELIEVING_DATE, new { @class = "datepicker" })

and then:

$(function () {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download