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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:10:17+00:00 2026-05-23T22:10:17+00:00

In my registration FORM, I have to allow the user to put his date

  • 0

In my registration FORM, I have to allow the user to put his date of birth. It is a requirement, that I show a SELECT for the day, a SELECT for the month and a SELECT for the year.

I have worked out a Html helper extension that creates that schema, and names the controls propertyName+".day", propertyName+".month" and propertyName+".year".

The idea is that in my view model, I define a DateTime property and then invoke this helper: @Html.DateSelect(m=>m.DateOfBirth) , but the problem is that I don’t know how to merge the previous 3 properties in a DateTime again.

I would get 3 POST parameters named dateofbirth.day, dateofbirth.month and dateofbirth.year.

How would it be done in MVC3?

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-05-23T22:10:18+00:00Added an answer on May 23, 2026 at 10:10 pm

    You will need to use a custom model binder:

    public class SplitDateTimeBinder : IModelBinder 
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
    
            ValueProviderResult day = bindingContext.ValueProvider.GetValue("propertyName.day");
            ValueProviderResult month = bindingContext.ValueProvider.GetValue("propertyName.month");
            ValueProviderResult year = bindingContext.ValueProvider.GetValue("propertyName.year");
    
            DateTime result = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day));
    
            return user;
        }
    }
    

    and register it in Global.asax:

    ModelBinders.Binders.Add(typeof(DateTime), new SplitDateTimeBinder());

    I’ve used int.Parse() in the example but you’ll probably want to use int.TryParse() and handle failed parses properly.

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

Sidebar

Related Questions

I have a product registration form that allows the user to add additional product
In my web application i have registration form, when user register i want to
I have created a registration form and now I am trying to put null
I have a user registration Form. If a new User register their account in
I have a registration form where this CSS rules apply. when user submits with
I have a form that once you select from a drop-down list and select
On my website, I have user accounts that are configurable with forms that allow
I have a user registration form, in which I am trying to display a
Ok, So I have added a Date of Birth section for the registration process.
I have registration form on my website that, using jquery I append default values

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.