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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:47:10+00:00 2026-05-21T05:47:10+00:00

Im creating a helper class to collect a users date of birth. I don’t

  • 0

Im creating a helper class to collect a users date of birth. I don’t want to use a date picker as I think they are a bit of a pain to use for dob.

I have created this so far

public static DateText DateTextFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> ex)
    {
        htmlHelper.ViewContext.Writer.Write(
          @"<div class=""date-control"">" +
          @"<input type='text' name='Day' id='Day' maxlength='2'/>" +
          @"<input type='text' name='Month' id='Month' maxlength='2'/>" +
          @"<input type='text' name='Year' id='Year' maxlength='4'/>" +
          @"<span>e.g. DD-MM-YYYY (31-03-1980)</span>" +
          @"<input type='hidden' name='Date' id='Date'/>" +
          @"</div>"

       );

        return new DateText(htmlHelper.ViewContext);
    }

I was going to create a script to get the data from the 3 textboxes and populate the hidden field ready for the http post.

So lets say I create my control like

    @Html.DateTextFor(model => model.DOB)

What do I need to modify in my helper to bind the hidden field to the model so when on postback I have the data I want?

Also when my page renders I am getting ‘My.Helpers.DateText’ text been added into the page, what is causing this?

Thanks for your help

  • 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-21T05:47:11+00:00Added an answer on May 21, 2026 at 5:47 am

    Cliet side, you would use JavaScript and intercept the post, populate the field and continue. Server side alternative would be combining the fields in your viewmodel, DOB read only, or you could also inherit from defaultModelBimder and handle the combining there (seems like overkill). I’m mobile so I apologize for not adding more detail.

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

Sidebar

Related Questions

I decided to use the singleton design pattern while creating a view helper class.
I'm creating a static helper class for web services I'm writing. I'm tapping into
I'm creating a Browser Helper Object using VS2008, C++. My class has been derived
I am creating a database helper class and for some of the methods within
I have been creating a helper class for the Facebook PHP API in order
I am creating a helper class and adding in a PDO instance into it.
After some hours creating a vb.net helper class for unit-tests and integrating moq into
I'm creating a DirectX 11 helper class that looks kind of like this: #import
I'm creating attached property. My attached class is helper:FocusDetail and has 2 property. second
Would creating a Month class be practical or is that a bit overzealous? I

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.