Persist a custom object across a postback

Posted on 2009-02-23
Medium Priority
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
  • 2
  • 2
LVL 11

Expert Comment

ID: 23715000
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

ID: 23715146

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

LVL 11

Accepted Solution

jmwheeler earned 2000 total points
ID: 23715187
Oh, sorry.

Add the [Serializable] attribute above to class declaration.


public class MyClass


Author Closing Comment

ID: 31550269
Thank you

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

749 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