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

The Archive Base Latest Questions

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

Say I have a page in my web application that lets a user update

  • 0

Say I have a page in my web application that lets a user update their contact information. Pretend in order to retrieve or save this information I have the following class:

public class User
{
    DataAccesClass dataAccesClass = new DataAccesClass()
    public string UserName {get;set;}
    public string Address {get;set;}
    public string EmailAddress {get;set;}

    public User(){}

    public static User GetUser(int userID)
    {
         User user = dataAccesClass.GetUser(userID); //
         return user;
    }

    public void Save()
    {
        dataAccesClass.SaveUser(this);
    }
}

Say that on my Page_Load event I create a new instance of my User class (wrapped in a !isPostBack). I then use it’s public properties to populate text fields on said page in my web application. Now the question is… When the page is posted back, what is the correct way to rebuild this class to then save the updated information? Because the class was created on Page_Load !isPostBack event it is not available. What is the correct way to handle this? Should I store it in a Session? ViewState? Should I simply rebuild it every post back? The User class in this example is small so that might influence the correct way to do it but I’d like to be able to take the same approach for much larger and more complex classes. Also, would this class be considered an acceptable business object?

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

    what is the correct way to rebuild this class to then save the updated information?

    I would say the best practice would be do not rebuild the class on every postback. You should build the data on the first request, set values on controls, then let the viewstate on those controls persist the data.

    If there is a potential for the data to need to be updated, tie re-generation of the object to an event indicating there is actual need to update.

    Should I store it in a Session? ViewState? Should I simply rebuild it every post back?

    Selecting whether to store the value in session or re-pull from the data layer should be based on the memory footprint of the object, the scalability requirements of the application, the costliness of the database operation, and the likelihood that the object will need to be accessed on any particular request. So I believe that is highly situational.

    Also, would this class be considered an acceptable business object?

    I don’t have a lot of experience with BLL’s but it looks like you’re on the right track.

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

Sidebar

Related Questions

Let's say I have an ASP.NET web application. I create an aspx page that
Let's say I have a web page that currently accepts a single ID value
Let's say that I have my ASP.NET web application in a directory called MyApp
Lets say we have a web-application where support guys can go and check various
Let's say I have a one-page Javascript-heavy web application. But for the rest of
Say I have a web site with a master page and an aspx page.
Let's say I have a page called display.php and the user is viewing display.php?page=3
Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG
Let's say you have a aspx page that does not rely on session, but
Let's say you have a profile page that can only be accessed by the

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.