473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Question on Page lifecycle...

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!!!
Jan 10 '06 #1
2 1700
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
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Diffident" wrote:
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!!!

Jan 11 '06 #2
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

"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:73**********************************@microsof t.com...
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!!!

Jan 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Epson Barnett | last post by:
I'm new to ASP.NET and have run across a problem several times while working on web apps. I often need to create content dynamically (based on an event) which contains dynamically created...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
3
by: malcolm | last post by:
Inside of a Page class, how do I capture the Request object values before the Page_Load event is called of that Page? I have a situation where I have many server controls on a Page that get...
0
by: Bryce Budd | last post by:
Hi, I have a webform which has several server controls attached. The entire form is data bound to custom objects. The collection objects are cached using the Cache object. In my use case, I...
2
by: Frankie | last post by:
I have a user control into which I insert a bunch of controls dynamically. I have it all working just fine - Everything is there on Postback, etc. I load this user control into a hosting ASPX...
4
by: Jeremy Holt | last post by:
Hi, In a windows.forms application I would BeginInvoke a delegate on the UI thread to collect data from a database. When the call returns to the AsyncCallback, if the Control.InvokeRequired =...
4
by: Diffident | last post by:
Hello All, I have a question which is pertinent to Page's lifecycle. I declared a protected static object (global variable within that class) whose value is set only once when the page is...
19
by: Mark Rae | last post by:
Hi, Is it possible to have programmatic access to the Page object in Application_BeginRequest, or is it too early in the lifecycle...? E.g. to be able to change a page's MasterPage...
2
by: Gary W. Smith | last post by:
I have a page that inherits from a base page that is currently overriding all of the On* events. For the most part I'm accomplishing everything I set out to do with the inheritance, but I wanted...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.