Persist a custom object across a postback

Posted on 2009-02-23
Last Modified: 2012-05-06
I have a custom object that contains other custom objects. I would like to persist it across a postback.

The parent object is a user profile object that contains a phone object, address object ect.

The application runs on a webfarm so I don't think I should use the session variable.

I tried View State but received an error related to serialization.

What do you suggest?

Question by:lateapex
    LVL 11

    Expert Comment

    What I typically do with dynamically added controls is to add them in my Page_Load procedure.  This will add the controls when the page loads and on every post back.  Also, if you give them the same ID each time the information entered in to the controls should repopulate from ViewState.

    Author Comment


    This is not a control, it's a custom object that has previously been populated with data.

    LVL 11

    Accepted Solution

    Oh, sorry.

    Add the [Serializable] attribute above to class declaration.


    public class MyClass


    Author Closing Comment

    Thank you

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now