Question: In my previous version, I used a Date Picker which could default as null as follows;

```
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>
<%:Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker" }) %>

```

Now I am using

```
@model DateTime?
@Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker" })) 

```

And this doesn't work.
When I click on a Date Field, I do not get a popup anymore.

So a date field looks like;

```
@Html.EditorFor(model => model.contract.GivenDate)

```

This is a DateTime field.
In my \_Layout I have;

 $(function () {
 $(".datePicker").datepicker({ showOn: 'both', dateFormat: 'dd/mm/yy' });
 });

Also I reference;

```
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.4.custom.min.js")" type="text/javascript"></script>

```

So what am I doing wrong?

Answer: 
The following works for me:

Inside `Views\Home\Index.cshtml`:

```
@model MvcApplication10.Models.FooBar
<!DOCTYPE html>
<html>
    <head>
        <title>Test DateTime?</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js")" type="text/javascript"></script>
        <link rel="Stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css" type="text/css" />

        <script type="text/javascript">
            $(function ()
            {
                $(".datePicker").datepicker({ showOn: 'both', dateFormat: 'dd/mm/yy' }); 
            });
        </script>

    </head>

    <body>
        @Html.EditorFor(model => model.GivenDate)
    </body>
</html>

```

Inside `Views\Shared\EditorTemplates\DateTime.cshtml`:

```
@model DateTime?
@Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker" })
@* you'll notice I also removed an extra ) at the end of the last line *@

```

And finally `Models\FooBar.cs`:

```
public class FooBar
{
    public DateTime? GivenDate { get; set; }
}

```

Can you try this out to see if there's any differences?
I've had problems with the jQuery date picker when my input elements don't have an ID (which I see will happen to you here because you aren't specifying a name when calling Html.TextBox), maybe try assigning one? E.g.

```
@Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker", id = "someUniqueDatePickerId" }))

```