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

  • Home
  • SEARCH
  • 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 135769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:50:34+00:00 2026-05-11T06:50:34+00:00

I’ve got a person object with a name and age property that implements INotifyPropertyChanged.

  • 0

I’ve got a person object with a name and age property that implements INotifyPropertyChanged. I want to hook this object up to an ASP.NET form so that the ‘name’ and ‘age’ properties bind to textboxes in a way that, when changes happen in either place (in the control or in the object) the other will get updated.

Do I create an intermediary class that listens to each textbox change events and the objects change events and handle the updates between them? What’s the best way to do this?

I’m unclear on how to get business objects and the UI talking to each other.

  • 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. 2026-05-11T06:50:35+00:00Added an answer on May 11, 2026 at 6:50 am

    I’ve stressed over this exact problem a lot.

    The short answer is, yes, an intermediate item.

    The trick is to NOT write ANY code per control. You should be able to place a GUI control on the screen (That may or may not take code), and then bind your business logic to it through a generic binding mechanism.

    I have defined the bindings through XML, through properties files, and through constant arrays–there are a million ways…

    You probably have to write code per TYPE of object bound (a listbox binds differently than a text control) and you may have to write validators (but specifying the parameters to the validators and which control the validators bind to should also be done in data)

    Now all that said, I’d be really surprised if some data-driven auto-binding mechanism didn’t already exist, Microsoft has been into that since VB first came out (although their implementations used to be pretty inflexible, I’m sure they do a better job now).

    I’m very insistent about the 0 lines of code per control because my job has typically involved configuring complex devices with dozens of pages of controls. A typical client/server system will have 7(!) lines of code PER CONTROL just to transport data from the DB, to the server, to the client, to the screen and back (this is a minimum for plain ole ‘dumb’ code with no smart binding tricks).

    0LOC/control may not be a requirement for everyone, but it’s a good goal.

    Comment response: I’ve done most of my stuff manually in Java, so I’m not sure I can be too much help with the specifics.

    Searching for C# and binding gave me this which looks promising, although it may be binding straight to a database which is too much IMO, it should bind to a business object, but the concepts should be the same.

    One way to create the bindings at first is to manually instantiate binding objects… (Please excuse my Java)

    TextControl textCtrl1=new TextControl('Name Goes Here'); new TextBinder(textCtrl1, personObject, nameField); 

    In Java, that second line gets tricky. When you are binding to a particular field, you HAVE to use reflection to find the setter and getter for that field of the personObject. In C# I think it should be easier.

    Anyway, the binder should add itself as a listener to the control and the object, then forward changes back and forth.

    Does that help any?

    Edit2: As you noticed, the hard part is noticing when your property is updated. Luckily, that is optional. More often than not, you don’t need to update the component once the object is set (I had to deal with this a few times when I had distributed UIs that could update each other).

    So, if you assume your object won’t change, the ‘Binding’ has to do the following:

    • get the value from the property and set it in the component.
    • add itself as a listener to the component.
    • store the property/object (if you can manipulate properties, you’re set here. If not, you need to store the object and property name, and use reflection)
    • bail and wait for an ‘updated’ event from your component.

    When you get the update from your component: – store the value in the property. – You may want to set an ‘Updated’ flag or store the original so that if you iterate through all the binding components, you can tell if any updates need to be saved/enable the ‘ok’ button.

    Your object should always be pretty much up-to-date now.

    As you build a form, you may want to put all your binding controls into a collection so that you can do a few other operations…

    • A ‘Save’ operation could call each binding control and tell it to copy from the control to the property, that way you don’t need to use a listener.
    • A ‘Reset’ operation can reset all the controls to their original value.
    • A ‘Test’ operation can ask each control if it’s been updated. . etc

    The neat thing about doing it this way is that every ‘Operation’ you wish to add is pretty trivial to add, but automatically affects the entire UI.

    You probably also want a little object hierarchy of controls with an abstract base ‘bind’ class, then a specific binder for each type of control (text field, number field, date, spinner, table, pulldown)–I think that’s about it.

    This can be very simple, but gains complexity rapidly. Try it with a text field and see what you can do. A simple text binding object should just be like 5 lines of code if you can pass ‘properties’ around in C#…

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I know there's a lot of other questions out there that deal with this
i got an object with contents of html markup in it, for example: string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.