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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:04:56+00:00 2026-05-30T05:04:56+00:00

I have a very confusing problem, and I am able to solve it, but

  • 0

I have a very confusing problem, and I am able to solve it, but there has to be a Out-Of-The-Box-Solution.

The situation is as following:
An user inputs on the client-side a date (i.e. with a date-picker) which outputs the following value to the textbox:

Mi 22.02.2012 (KW 8)

I have a Button which posts my form with this textbox to an controller-action.
Let’s say you have the following controller action which takes a MyType as Parameter

[HttpPost]
public ActionResult Create(MyType model)
{
    //model.Date is always null
    //(or in case the DateTime is not Nullable<T>, the value is DateTime.Min
}

public class MyType
{
    public DateTime? Date { get; set; }
}

The question is simple:
How do I map the input to the DateTime?

I do not want to add properties to my class like in the following example:

public class IDontWantThis
{
    public DateTime? Date { get { /* Some custom string parsing with DateText */ } }
    public string DateText { get; set; } //this would be the auto-mapped property
}
  • 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-30T05:04:57+00:00Added an answer on May 30, 2026 at 5:04 am

    How a date is displayed in the view is of no concern to the controller.

    I would add a hidden field with the name of the property you want the datetime to map on the viewmodel (Date). On the client, using javascript, you can format this date any way you want, as long as the hidden field contains the datetime you need to work with.

    So let the datepicker store the selected date twice, once with your weird date formatting for display and another time in a hidden field in a common format the modelbinder will understand.

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

Sidebar

Related Questions

I have run into a very confusing situation with maps on the iPhone. Everything
I am having a very confusing problem with an application I have been working
I have a problem that is very confusing for me. In the constructor of
One thing I have continually found very confusing about using an object database like
I am a beginner of python and have a question, very confusing for me.
We have very strange problem, one of our applications is continually querying server by
i have very simple problem. I need to create model, that represent element of
I have very little experience using Sharepoint but a good amount using Visual Studio
I'm new to OS X programming but generally liking it. I have the following
I just saw a very odd thing, I have a co-worker who has their

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.