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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:03:03+00:00 2026-06-01T14:03:03+00:00

I am currently trying to figure out how you can bind multiple fields in

  • 0

I am currently trying to figure out how you can bind multiple fields in an MVC 3 view to 1
property on a view model and what is recommended when trying to achieve this.

Using an example for the number of minutes (only) that it takes to prepare something.

The form might look something like this:

Preparation time – Hours: [ 1 ] Minutes: [ 30 ]

and the submitted form values need to be converted into minutes and bound to the PreparationTimeInMinutes property of the ViewModel.

ViewModel property:

public short PreparationTimeInMinutes { get; set; }

and the View is strongly typed to the ViewModel and currently has the below:

<div class="editor-label">
    @Html.LabelFor(model => model.PreparationTimeInMinutes)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.PreparationTimeInMinutes)
    @Html.ValidationMessageFor(model => model.PreparationTimeInMinutes)
</div>

Here are a few things that I began thinking about in order to achieve this.

  1. Change the PreparationTimeInMinutes property to a ViewModel that has an hour & minute
    property and create Editor and display templates for it so that
    MVC3 can sort out the binding and validation?
  2. Use javascript and a hidden field for the preparation time.
  3. Some other approach that lets you use the MVC model binding to do this sort of thing?

Does anyone have any suggestions on best practice for this sort of thing? or if I am way off.

Please let me know. 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-01T14:03:04+00:00Added an answer on June 1, 2026 at 2:03 pm

    You should use the first option.
    This is exactly what editor templates are made for.

    If you want to, you can create a custom ModelBinder to bind two POSTed values to a single number (along with a similar editor template) and apply an attribute to the property to select that ModelBinder.
    However, that would probably be overkill.

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

Sidebar

Related Questions

Currently I am trying to figure out how I can add dynamic query string
I'm trying to figure out what can cause this error in Java: Invalid access
I am currently trying to figure out a way on how I can possibly
I'm trying to figure out how I can prevent multiple of the class asks
I'm currently trying to add an MSChart to a partial view in ASP.NET MVC
I am currently trying to figure out how sms classes are correctly represented in
I am currently trying to figure out how to do move semantics correctly with
I am currently trying to figure out a way to have an Android application
I am currently trying to figure out a way to calcute the size of
I am currently trying to figure out what click event handlers have attached to

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.