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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:58:19+00:00 2026-05-12T19:58:19+00:00

In my applications I always end up implementing a Model-View-Presenter pattern and usually end

  • 0

In my applications I always end up implementing a Model-View-Presenter pattern and usually end up scrapping my View object from the screen with a get property.

For example

Person IBasicRegistration.Person
{
 get
 {
  if (ViewState["View.Person"] == null)
   ViewState["View.Person"] = new Person();

  var Person = (Person) ViewState["View.Person"];

  Person.Email = txtEmail.Text.Trim();
  Person.FirstName = txtFirstName.Text.Trim();
  Person.LastName = txtLastName.Text.Trim();
  Person.Zip = txtZip.Text.Trim();
  Person.Phone = txtPhone.Text.Trim();
  Person.ResidentPersonLicenseState = 
        EnumerationParser.Parse<States?>(ddState.SelectedValue);

  return Person;
 }
}

However during debugging I’ve noticed when I access IBasicRegistration.Person in my Presenter/Model that I get quite a few traversals of my get { } property.

I started thinking this pattern seems to very similar to the INotifyPropertyChanged pattern and I started thinking about implementing a similar pattern and having each textfield implement an OnChanged event that would update it’s related value in the person object that sits in the view state however the further I thought on that it require numerous server requests every time a person mouses out of a field and seems like it could lead to scalability issues at some point.

My next thought would it just make sense to create an IsDirty flag and wrap my code where it touches the fields similar to:

Person IBasicRegistration.Person
{
 get
 {
  if (ViewState["View.Person"] == null)
   ViewState["View.Person"] = new Person();

  var Person = (Person) ViewState["View.Person"];

  if(IsDirty)
  {
      Person.Email = txtEmail.Text.Trim();
      ...others

      IsDirty = false;
  }

  return Person;
 }
}

And set on any method that invokes a post back, (ie usually just the submit button) to set IsDirty = true and then it will skip repeating alot of work for no reason.

Has anyone come up with something more elegant for this task?

  • 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-12T19:58:19+00:00Added an answer on May 12, 2026 at 7:58 pm

    I think where the disconnect is happening is that you typically implement a view while in your get you are create the view. A typical scenario is that a form implements a view interface and then register itself (or is registered) within the application object. Then anytime you need to find out what has been entered for a person you use the various properties of the view.

    For example to find out what you entered for the first name you would go

     myVariable = PersonView.FirstName();
    

    In your example you are pulling the STATE of the view every time you access person. Even if you just wanted the email you are pulling everything and putting it in a state variable.

    Now this if the data structure Person was part of your model. Then this could be OK. You pull the person out once when it is changed. Modify or add it to the model then everything else (reports ,etc) would be looking at the model.

    However your question suggests that that it is being hit over and over again. Which leads me to think that Person is being accessed directly from the view for a variety of reasons. In this case I would put properties on the view allowing access to the individual members.

    Or I would refactor the design so that everything uses the model for the data with the model being updated everytime the view changes. I suspect you probably don’t want to do this at this point and hence the best way is to use individual properties.

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

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer you can maintain a counter (e.g. bgnum) and concatenate it… May 12, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer You can turn on build timing as a start... although… May 12, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer If the table already exists, then you can alter it… May 12, 2026 at 9:17 pm

Related Questions

Summary I recently had a conversation with the creator of a framework that one
I'm thinking of switching from using PHP to Python for web applications, but I
Here's the scenario: You have an ASP.Net application supported by a Microsoft SQL Server
The users of my web application may have more than one browser window open
I created a .NET application years ago without thinking too hard about the file

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.