Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6386913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:05:12+00:00 2026-05-25T03:05:12+00:00

In my previous version, I used a Date Picker which could default as null

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:05:13+00:00Added an answer on May 25, 2026 at 3:05 am

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a design question, to whet the guru's appetite. In a previous version,
Context I have written a TreeList/TreeGrid (i.e. tree with columns) control that inherits the
I've used the new installers from http://www.riverbankcomputing.co.uk/software/pyqt/download for Python 2.6 x86_64 and I've a
I'm trying to setup a (I thought) fairly simple versioning system for static html
I am preparing my app to work smoothly with honeycomb. I have an small
Why are some rake tasks not listed by rake -T ? Like db:migrate:reset ?
I just read Ben Alman 's article on Immediately-Invoked Function Expressions and wondered about
I have a calendar that was previously divided into 30min blocks. I am updating
I have a rather odd CSS problem. I am bringing in an Internet Explorer
How would you parse a variable length sequence of bytes where first bit (BigEndian)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.