Question on Page lifecycle...

G

Guest

Hello All,

I have a question which is pertinent to Page's lifecycle.

I declared a protected static object (global variable) whose value is set
only once when the page is loaded. Will that object's value be accessible
during consequent postbacks or is it set to null after HTML is rendered
initially?

I am assuming that it would be set to null because all the objects are
destroyed since Page object is killed after HTML has been rendered. In this
case ViewState does not make sense because it is an object and not a server
control.....correct?

Am I right or can anyone please explain me the concept?

Thanks a bunch!!!
 
G

Guest

Diffident,
It depends where your object is declared. if you declare a static object in
the Global class (global.asax) this remains alive. Since a page class'
lifecycle is limited, meaning as soon as the generated response stream is
sent out to the browser it is extinguished, it doesn't make sense to do this
inside a page class.
Peter
 
E

Eliyahu Goldin

Session variable live in the scope of application. This means that not only
consequent postbacks within the same session will access the same value, but
also other sessions of the same applications will do.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top