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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:47:15+00:00 2026-05-13T15:47:15+00:00

I have an object called Time public class Time{ public int Hour {get;set;} public

  • 0

I have an object called Time

public class Time{
   public int Hour  {get;set;}
   public int Minute {get;set;}     

   public static Time Parse(string timeString){
   //reads the ToString()'s previous output and returns a Time object
   }

   override protected string ToString(){
   //puts out something like 14:50 (as in 2:50PM)
   }
}

So what I want is for the automatic model binding on the Edit or Create action to set this Time instance up from a string (i.e. feed the Parse method with the string and return the result).

The reason I am doing this is that I will have a DropDownList with selectable times. The value of each option will be the parser readable string.

Can anyone provide an example BindModel method from the IModelBinder interface?

  • 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-13T15:47:16+00:00Added an answer on May 13, 2026 at 3:47 pm

    OK, I found what I wanted. Model Binding by Scott Hanselman You are a legend Scott.

    The key component was using the “bindingContext.ModelName” to get the name of the key and then pull the value from the value provider like so:

    bindingContext.ValueProvider.GetValue(bindingContext.ModelName).AttemptedValue
    

    Of course that’s a fairly naive implementation, but it got me started.

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

Sidebar

Related Questions

I have a class called Book; class Book { public string Name { get;
I have an object called Contact. A Contact has a relationship with a set
I have an object class called BOM. It has a method, getChildItem() which returns
I have a CognitiveEntity class, defined this way: class CognitiveEntity : public Object {
i have the code as below : class Singleton { private: int i; static
I have the following situation: class A { public: A(int whichFoo); int foo1(); int
Suppose we have a class in C++ class X { int i; public: X(int
I have an object called Layer that has some attributes and some methodes. i
I have an object called Document that has a one-to-many relationship with DocumentPersonCc. I
I have a object called: SqlCeDataReader rdr; Because SqlCeDataReader does not have HasRows function,

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.