473,654 Members | 3,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.....cor rect?

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

Thanks a bunch!!!
Jan 10 '06 #1
2 1732
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.....cor rect?

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*******@disc ussions.microso ft.com> wrote in message
news:73******** *************** ***********@mic rosoft.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.....cor rect?

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
1011
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 linkbuttons (or other webcontrols). These linkbuttons have to be created after events are processed, and so these linkbuttons cannot have handlers added to them because they are too late in the page lifecycle for the handlers to register. An example:
2
3617
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
2016
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 created in the constructor of my Page, but I need them to know about some info that get's set via the Page_Load from the Request (and even Session for that matter) thanks! Dave
0
1138
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 have to update my database, synchronize my cached collection and refresh my UI. After my database update I call dropdownlist1.databind() and my items are exactly the same when they should be less 1 item. If I understand the "control execution...
2
4816
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 page at runtime during the Page_Load event procedure of the hosting ASPX page. Question: Would it be better to load the user control from the hosting page's OnInit event rather than Page_Load? Does it matter or not? I ask because I understand...
4
2060
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 = True, I would then have the Control.BeginInvoke(New AsyncCallback(AddressOf GetDataCallback), New Object() {ar}). How would one achieve the same thing on an asp.net page (without using a webseervice)? In the code below, because the...
4
343
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 loaded. Will that object's value be accessible during consequent postbacks or is it set to null after HTML is rendered initially?
19
3580
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 dynamically, something like: protected void Application_BeginRequest(Object sender, EventArgs e) { if (Session == "True")
2
3184
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 to get a little more information to lock down what I think I know and also to answer a couple little questions. Given a base page, and the page inheriting it, as I understand it, the page lifecycle flows like this: 1) Page is requested
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.