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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:56:34+00:00 2026-05-30T03:56:34+00:00

In my model, the field Length is a TimeSpan with the following Data Annotation:

  • 0

In my model, the field Length is a TimeSpan with the following Data Annotation:

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{h\\:mm}")]

which I used per the suggestion here. I want the resulting textbox to display the current value for Length in hours and minutes.

However, in MVC 3 this doesn’t seem to work anymore, because it causes a FormatException. This exception occurs whether or not Length has an existing value.

Visual Studio adds, “When converting a string to DateTime, parse the string to take the date before putting each variable into the DateTime object.” I don’t even know what that means. My variable is a TimeSpan, not a string, so why is it attempting to do a string conversion in the first place? The dialog box reporting the exception gives a dead link.

This is the code in my view:

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

The exception occurs at Html.EditorFor(). I’m not sure what I’m missing here, does anyone have any suggestions? 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-30T03:56:36+00:00Added an answer on May 30, 2026 at 3:56 am

    Your format specifier needs the position identifier:

    {0:h\\:mm}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field in my Rails model that has max length 255. I'm
My user model has validates :password, :presence => true, :confirmation => true, :length =>
I have a Entry model which has a Pushes field and I want each
I created a Field to save the weekdays, used in a model like that
I have a model Client which contains an array field. In the client.rb model
I have a File model, which store path field - path in the filesystem
I have an inline on a model with data with a fixed length, that
I have the following validation in my model ( User ): validates :first_name,:length =>
I'm working on a data audit web applicaton which has a model containing several
I have written a custom Django Model Field to store dateutil.relativedelta 's. The field

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.