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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:44:39+00:00 2026-06-11T05:44:39+00:00

I have an MVC 3 website where I display dates in forms using: <div

  • 0

I have an MVC 3 website where I display dates in forms using:

<div class="editor-label control-label">
     @Html.LabelFor(m => m.rrsfWoman.DateOfBirth)
</div>
<div class="editor-field controls">
     @Html.EditorFor(m => m.rrsfWoman.DateOfBirth)
     @Html.ValidationMessageFor(m => m.rrsfWoman.DateOfBirth)
</div>

The date of birth is defined in the rrsfWoman class as

public DateTime WomansDateOfBirth { get; set; }

My problem is that as the date of birth field has by default a value of MinDate. Is there a way I can supress the display of the date as 1/01/0001 without making the field nullable.

Thanks

  • 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-06-11T05:44:41+00:00Added an answer on June 11, 2026 at 5:44 am

    Is there a way I can supress the display of the date as 1/01/0001
    without making the field nullable.

    The correct way to achieve that is to make the date nullable in your view model. If you don’t do that later you will struggle with model binding as well because a non-nullable DateTime field cannot be bound to an empty string and you will have to write custom model binders and stuff to make it work. You will make your life miserable if you don’t use view models.

    This being said, if you want to go against good practices, you could define a custom editor template for the DateTime type that will perform the check and use an empty value but honestly I don’t recommend you doing that:

    ~/Views/Shared/EditorTemplates/DateTime.cshtml:

    @model DateTime
    
    @if (Model == default(DateTime))
    {
        @Html.TextBox("", "")
    }
    else
    {
        @Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net mvc website and am using javascript treemap control to display
I have the following view definition in my asp.net mvc website: <% Using Ajax.BeginForm(UsrCtlChangePassword,
I'm writing a MVC website and using jqGrid. I have managed to get it
I have developed a website using Asp.Net MVC which uses a SQL CE database
i have as asp.net-mvc website and we are migrated a popup from using PartialView()
Background: I have an MVC layout (master) view which uses @Html.RenderAction to display a
I am building a website using ASP.NET MVC and entity framework. I have a
I have a MVC website that sits on top of a WCF service. The
I have built a MVC website on IIS6. I used the built-in ASP.NET Security
I have an ASP.NET MVC website where I've established a system of Permissions. There

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.