Thursday, March 29, 2012

object persistence

I instatiate an object first time when an asp.net page loads. But when
the page reloads after Post Back, I get an error saying the object
does not exist. What do I need too do to make object persistant on
server?

Help appreciated.Try putting the object into Session State or ViewState.

Sesssion("MyObject") = oMyObject

Then on postback:
oMyObject = CType(Session("MyObject"),cMyObject)

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Developer for Hire

"Atif Jalal" <matif@.hotmail.com> wrote in message
news:b7af12d4.0308120905.51c736bd@.posting.google.c om...
> I instatiate an object first time when an asp.net page loads. But when
> the page reloads after Post Back, I get an error saying the object
> does not exist. What do I need too do to make object persistant on
> server?
> Help appreciated.
Every time the Page reloads, all objects in it must be rebuilt from scratch.
Either, as Steve suggested, persist the object in some caching mechanism, or
re-create the object with each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Atif Jalal" <matif@.hotmail.com> wrote in message
news:b7af12d4.0308120905.51c736bd@.posting.google.c om...
> I instatiate an object first time when an asp.net page loads. But when
> the page reloads after Post Back, I get an error saying the object
> does not exist. What do I need too do to make object persistant on
> server?
> Help appreciated.

0 comments:

Post a Comment