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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:08:04+00:00 2026-05-23T23:08:04+00:00

My goals are: Display all dates in d MMM yyyy format Default/existing values on

  • 0

My goals are:

  • Display all dates in d MMM yyyy format
    • Default/existing values on first page load
    • Anything entered by the user, then round-tripped via the server
  • Add class="behaviour-date-picker" to the input field so that I can show a jQuery date picker
  • Build on top of the System.ComponentModel.DataAnnotations infrastructure
  • Still show bad data values such as 12 Joone 2010 after a server roundtrip, with the appropriate validation error message

Here’s an example model:

public class DebugDatesStub
{
    [DataType(DataType.Date)]
    public DateTimeOffset Date { get; set; }
}

The DisplayFormat attribute doesn’t solve my scenario because it doesn’t apply to round-tripped values. (User fills in form, submits it, gets the same form back because of some server-side validation issue – date is still shown in the original format they entered instead of being reformatted.)

  • 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-23T23:08:05+00:00Added an answer on May 23, 2026 at 11:08 pm

    Render the field on the page with:

    @Html.EditorFor(m => m.Date)
    

    Create this code in ~\Views\Shared\EditorTemplates\Date.cshtml:

    @using System.Globalization
    @model DateTimeOffset?
    
    @{
        var propertyState = ViewData.ModelState[ViewData.ModelMetadata.PropertyName];
        var displayValue =
            propertyState != null && propertyState.Errors.Any() ? propertyState.Value.AttemptedValue :
            ViewData.Model.HasValue ? string.Format("{0:d MMM yyyy}", ViewData.Model.Value) :
            string.Empty;
    
        ViewData.ModelState.SetModelValue(
            ViewData.ModelMetadata.PropertyName,
            new ValueProviderResult(displayValue, displayValue, CultureInfo.CurrentCulture));
    }
    
    @Html.TextBoxFor(m => m, new { @class = "behaviour-date-picker" })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my goal is to write a stored proc that can collect all field values
On a Drupal app, my goal is to display a page with a couple
My goals are focused on software application development, and maybe web application development, but
One of my goals over the next few months is to get familiar with
One of my goals is to be able to deploy a new version of
I'm refurbishing a simple web-app that our field techs use. One of my goals
I'm trying to display events in calendar generated by calendar_date_select plugin for Rails. I
My ultimate goal is to traverse an XSD document and display a TreeView (Silverlight
Is there a proper way to display text at the descent height of a
Goal: Display different context menu if right clicking a row from the listview or

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.