473,387 Members | 1,303 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,387 software developers and data experts.

"Page" class and utility class

Hello All,

I have written a webform which is by default derived from "Page" class. I
have coded another utility class with few methods and an object of this class
is instantiated from the webfom class.

Methods inside the utility class set few global variables which act as
mediums of persistence to hold data. Now my question is all works fine during
my initial request and all the global variables are set correctly, but during
later requests I doubt that global variables are holding null references. Can
anyone give me a suitable explanation on this?

I know that Page class is completely destroyed in the "Unload" method of the
lifecycle but how about the utility class? Would it even be destroyed along
with the webform class?

Thanks for your pointers!!
Nov 19 '05 #1
5 2280
You can persist through app variables, to some extent. Beyond that use a
DB/File/etc to persist data.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
Hello All,

I have written a webform which is by default derived from "Page" class. I
have coded another utility class with few methods and an object of this
class
is instantiated from the webfom class.

Methods inside the utility class set few global variables which act as
mediums of persistence to hold data. Now my question is all works fine
during
my initial request and all the global variables are set correctly, but
during
later requests I doubt that global variables are holding null references.
Can
anyone give me a suitable explanation on this?

I know that Page class is completely destroyed in the "Unload" method of
the
lifecycle but how about the utility class? Would it even be destroyed
along
with the webform class?

Thanks for your pointers!!

Nov 19 '05 #2
Does your reply mean that the utility class's object is also destroyed in the
Page's Unload method?
"Curt_C [MVP]" wrote:
You can persist through app variables, to some extent. Beyond that use a
DB/File/etc to persist data.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
Hello All,

I have written a webform which is by default derived from "Page" class. I
have coded another utility class with few methods and an object of this
class
is instantiated from the webfom class.

Methods inside the utility class set few global variables which act as
mediums of persistence to hold data. Now my question is all works fine
during
my initial request and all the global variables are set correctly, but
during
later requests I doubt that global variables are holding null references.
Can
anyone give me a suitable explanation on this?

I know that Page class is completely destroyed in the "Unload" method of
the
lifecycle but how about the utility class? Would it even be destroyed
along
with the webform class?

Thanks for your pointers!!


Nov 19 '05 #3
I believe it will be yes.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
Does your reply mean that the utility class's object is also destroyed in
the
Page's Unload method?
"Curt_C [MVP]" wrote:
You can persist through app variables, to some extent. Beyond that use a
DB/File/etc to persist data.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
> Hello All,
>
> I have written a webform which is by default derived from "Page" class.
> I
> have coded another utility class with few methods and an object of this
> class
> is instantiated from the webfom class.
>
> Methods inside the utility class set few global variables which act as
> mediums of persistence to hold data. Now my question is all works fine
> during
> my initial request and all the global variables are set correctly, but
> during
> later requests I doubt that global variables are holding null
> references.
> Can
> anyone give me a suitable explanation on this?
>
> I know that Page class is completely destroyed in the "Unload" method
> of
> the
> lifecycle but how about the utility class? Would it even be destroyed
> along
> with the webform class?
>
> Thanks for your pointers!!


Nov 19 '05 #4
it depend on how the utility class is coded and used. if you webform creates
an instance of the utility class, it will be released at the end of the page
process. all pages will see there own instance data. if the utiltity class
has any shared or static variables, these live the life of the appdomain,
and any page request sees the same values. if you do not use some locking
techinque you will have threading issues.

-- bruce (sqlwork.com)

"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
| Hello All,
|
| I have written a webform which is by default derived from "Page" class. I
| have coded another utility class with few methods and an object of this
class
| is instantiated from the webfom class.
|
| Methods inside the utility class set few global variables which act as
| mediums of persistence to hold data. Now my question is all works fine
during
| my initial request and all the global variables are set correctly, but
during
| later requests I doubt that global variables are holding null references.
Can
| anyone give me a suitable explanation on this?
|
| I know that Page class is completely destroyed in the "Unload" method of
the
| lifecycle but how about the utility class? Would it even be destroyed
along
| with the webform class?
|
| Thanks for your pointers!!
Nov 19 '05 #5
Diffident wrote:
I have written a webform which is by default derived from "Page" class. I
have coded another utility class with few methods and an object of this class
is instantiated from the webfom class.

Methods inside the utility class set few global variables which act as
mediums of persistence to hold data. (abridged)

I know that Page class is completely destroyed in the "Unload" method of the
lifecycle but how about the utility class? Would it even be destroyed along
with the webform class?

You haven't got "global variables" in object oriented programming
environments, so I except that you refer to either:
1. Field on the utility class
2. Application or Session variables.

If the utility class is instantiated from the webform class and no other
"living" class holds a reference to the class the utility class is
marked for garbage collection. A new instance of the utility class will
be created when a new request for the page is handled.
If you store values data in the fields of the utility class (scenario 1)
the data dies with the class.
If you store the data in either session or application variables
(scenario 2), the data can be retrieved on subsequent requests.

A third posibility is to store the data in the page's view state.
To store a value in and retrieve it from the view state do this (C#):
if (Page.IsPostBack) {
// Read from view state
RegTot=(string) ViewState["MyValue"];
} else {
// Store in view state
ViewState["MyValue"] = RegTot;
}

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 19 '05 #6

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

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
7
by: Ken Fine | last post by:
My well-heeled clients would like a tool that I could build into a web application that would suck down the entire contents a remote webpage and store it on a local filesystem. I know how to...
1
by: Davíð Þórisson | last post by:
asking a lot these days... how would I ever learn .Net without the newsgroups!! Well I'm stuck on yet another point. All pages on my web have a user control (initialise) that handles for example...
4
by: Shawn Berg | last post by:
A web site I am working on is built completely in classic ASP, and allows the user to choose different "skins" for the site. The term "skin" being used very generically. When a user selects a Skin...
1
by: digitalego | last post by:
Sorry if the title is a little confusing... Here is the problem. I am working with a "default.aspx" page that uses a user control I made: ------------------------------ | default.aspx ...
3
by: cmay | last post by:
In reading some documents from the Patterns and Practices group, I had a question about the example given for the Page Controller pattern. (I have posted the code for the BasePage below) In...
1
by: R.A.M. | last post by:
Hello, I have written an .aspx page which calls Calendar.aspx page to select birth date which should be assign to some text box control on first page. Here's the code of first page: Birthdate:...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
1
by: epatrick | last post by:
I have a series of custom controls developed under ASP.NET 1.1, and I've successfully migrated to ASP.NET 2.0. I have also developed a custom class dervied from System.Web.UI.Page, called...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.