Postback frustration... please advise

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
Can anyone tell me what is the best way to persist a complex object across postbacks in ASP.NET

eg
* I have a Person class with methods to edit the person's info
* I navigate to my ASP.NET page "person_edit.aspx?PersonID=5321
* On Page_Load...If Not IsPostback I instantiate the object based on the Request("PersonID")
* I bind form fields to the properties of the object
* I execute 1 or more subs to edit the person's info

q
* On every postback where data in the object is changed, do I need to re-instantiate the object in order to databind again

note: I understand I still have to databind again... what I don't know is... is this business of having my object destroyed and recreated half a dozen times the norm? or is is bad design practice

Techniques I've tried are putting the object in Session, or putting the object in ViewState
Both of these can be made to work to some degree.. though not all that well.. In certain cases
depending on the kind of change I make to my object, I wind up re-loading it into my Session o
ViewState variable ANYWAY... Plus, based on everything I read about performance and scalability
I should NOT be putting complex objects in EITHER Session OR ViewState

Can anyone please advise

Stateless programming stinks.
 
Hi Artifact,

Your object is not persistent in ASP.Net, it is destroyed everytime when
your page is sended back to the client.

The application belong to the server and static/shared classes as well as
the cach belong to the application. (Shared by all users).

So when you do not identify them in those (while it is than growing, without
that you are able to kill them in another way than using a timer mechanisme
in my opinion), you are sticked to the viewstate of the session.

I myself see at this moment no benefit of creating data classes in a aspnet
application. I think that a right selected dataset/datatable is the best
thing to use for that and set that in a session and as a bad alternative in
a viewstate.

Just my thought about this.

Cor
 
Back
Top