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 6096139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:53:30+00:00 2026-05-23T12:53:30+00:00

I was checking out this link: http://blogs.msdn.com/b/stuartleeks/archive/2011/01/25/asp-net-mvc-3-integrating-with-the-jquery-ui-date-picker-and-adding-a-jquery-validate-date-range-validator.aspx which describes creating a jquery datepicker for

  • 0

I was checking out this link:

http://blogs.msdn.com/b/stuartleeks/archive/2011/01/25/asp-net-mvc-3-integrating-with-the-jquery-ui-date-picker-and-adding-a-jquery-validate-date-range-validator.aspx

which describes creating a jquery datepicker for MVC for date selections in edits.

Sure the tutorial works fine but only works for edits and not creates.

It has a model of:

public class Foo
    {
        public string Name { get; set; }
        [DataType(DataType.Date)]
        public DateTime Date { get; set; }
    }

I modified its edit to create a create like:

@model DatePickerTemp.Models.FooEditModel @{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>
    Create</h2> 
@Model.Message
@using (Html.BeginForm())
{ 
    @Html.EditorFor(m => m.Foo)
    <input id="submit" name="submit" type="submit" value="Save" />
}

}

The other code uses some jquery:

$(document).ready(function () {
    $('.date').datepicker({dateFormat: "dd/mm/yy"});
});

for anything with class .date:

There is another piece of code:

@model DateTime
@Html.TextBox("", Model.ToString("dd/MM/yyyy"), new { @class = "date" })

which sets the class on the objects of type:

[DataType(DataType.Date)]

to create a jquery datepicker.

The problem is this type is a non nullable type so when you run the create you get:

The model item passed into the dictionary is null, but this dictionary requires a non-null model item of type 'System.DateTime'.

Does anyone know how to modify the code to make the create work?

  • 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-23T12:53:31+00:00Added an answer on May 23, 2026 at 12:53 pm

    Something like:

     @model DateTime?
        @Html.TextBox("", Model.HasValue && Model.Value != DateTime.MinValue ? Model.Value.ToString("dd MMM yyyy") : string.Empty, new { @class = "datePicker" })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just went through some MVC tutorials after checking this site out for a
I was checking out this question which has this code - (NSArray *) percentagesRGBArray:(float[])
I am just checking out F#, so apologies if this is a silly question,
I was checking out this example at tutsplus and this is what I found.
i was checking out this excellent demo of drop down menus created with CSS,
Here's a jsFiddle link: http://jsfiddle.net/HunEj/ So you can click on the checkbox, and it'll
It seems this is a common question/problem but despite checking out a number of
After checking out code for the first time from a repository into Eclipse using
After checking out a branch in a repository git always prints a list of
I was checking out Intel's whatif site and their Transactional Memory compiler (each thread

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.