473,399 Members | 2,858 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,399 software developers and data experts.

Page class in ASP.NET

Hi ,
I am new to ASP.NET. I was reading about Page class in one
of the ASP.NET books and am confused with the way the Page
class is actually implemented.What is didnt understand in
when is this Page class created ? Is it when the ASPX file
is requested for the first time ? Is this executable Page
object saved somewhere in the server hard disk space or is
it available only in the memory ? I would really like to
know more about how all this is implemented in ASP.NET.So
if you know the answers to these or you have links to any
pages which could be of any help please do let me know.

Thanx in advance,

Cheers.........
Nov 17 '05 #1
5 1806
> when is this Page class created ? Is it when the ASPX file
is requested for the first time ?
The Page class is created at design time by the developer. It is
instantiated at run-time, with the first request for the Page, and cached in
memory, so that future requests for the Page don't have to re-instantiate
it. Of course, the Page can expire from the cache (after a period of no
requests for it), in which case it is re-instantiated with the next request.
Is this executable Page
object saved somewhere in the server hard disk space or is
it available only in the memory ?
A class is an in-memory object. In special circumstances, classes can be
serialized and stored in other media, but this is not typical.
if you know the answers to these or you have links to any
pages which could be of any help please do let me know.
You can get the entire .Net SDK for free from Microsoft at the following
URL:

http://www.microsoft.com/downloads/d...displaylang=en

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"ozie" <oz****@indiatimes.com> wrote in message
news:01****************************@phx.gbl... Hi ,
I am new to ASP.NET. I was reading about Page class in one
of the ASP.NET books and am confused with the way the Page
class is actually implemented.What is didnt understand in
when is this Page class created ? Is it when the ASPX file
is requested for the first time ? Is this executable Page
object saved somewhere in the server hard disk space or is
it available only in the memory ? I would really like to
know more about how all this is implemented in ASP.NET.So
if you know the answers to these or you have links to any
pages which could be of any help please do let me know.

Thanx in advance,

Cheers.........

Nov 17 '05 #2
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
when is this Page class created ? Is it when the ASPX file
is requested for the first time ?
The Page class is created at design time by the developer. It is
instantiated at run-time, with the first request for the Page, and cached

in memory, so that future requests for the Page don't have to re-instantiate
it. Of course, the Page can expire from the cache (after a period of no
requests for it), in which case it is re-instantiated with the next

request.

Actually, Kevin, it's more complicated than this.

When you create a .aspx page, you are creating an anonymous class which
derives from System.Web.UI.Page. If you are using codebehind, you're
creating a named class which derives from Page, and the anonymous class
derives from the names class.

An instance of the class is created for each request to that page. The
methods and events of the class are executed in a well-defined order, and
the resultant HTML (or other data) is sent back to the client. At the end of
the request, the instance of the class is destroyed.

ASP.NET may cache the output of the page. When a request comes in for a
cached page, the output is sent to the client and another instance of the
class is _not_ created.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #3
John,

What is the names class? can't find it
What is a named class? vs. un-named class? if any exist?
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
when is this Page class created ? Is it when the ASPX file
is requested for the first time ?
The Page class is created at design time by the developer. It is
instantiated at run-time, with the first request for the Page, and cached in
memory, so that future requests for the Page don't have to
re-instantiate it. Of course, the Page can expire from the cache (after a period of no
requests for it), in which case it is re-instantiated with the next

request.

Actually, Kevin, it's more complicated than this.

When you create a .aspx page, you are creating an anonymous class which
derives from System.Web.UI.Page. If you are using codebehind, you're
creating a named class which derives from Page, and the anonymous class
derives from the names class.

An instance of the class is created for each request to that page. The
methods and events of the class are executed in a well-defined order, and
the resultant HTML (or other data) is sent back to the client. At the end

of the request, the instance of the class is destroyed.

ASP.NET may cache the output of the page. When a request comes in for a
cached page, the output is sent to the client and another instance of the
class is _not_ created.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #4
You got me there, John.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
when is this Page class created ? Is it when the ASPX file
is requested for the first time ?
The Page class is created at design time by the developer. It is
instantiated at run-time, with the first request for the Page, and cached in
memory, so that future requests for the Page don't have to
re-instantiate it. Of course, the Page can expire from the cache (after a period of no
requests for it), in which case it is re-instantiated with the next

request.

Actually, Kevin, it's more complicated than this.

When you create a .aspx page, you are creating an anonymous class which
derives from System.Web.UI.Page. If you are using codebehind, you're
creating a named class which derives from Page, and the anonymous class
derives from the names class.

An instance of the class is created for each request to that page. The
methods and events of the class are executed in a well-defined order, and
the resultant HTML (or other data) is sent back to the client. At the end

of the request, the instance of the class is destroyed.

ASP.NET may cache the output of the page. When a request comes in for a
cached page, the output is sent to the client and another instance of the
class is _not_ created.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #5
"MS News (MS ILM)" <sq**********@hotmail.com> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
John,

What is the names class? can't find it
What is a named class? vs. un-named class? if any exist?


When using codebehind, you might have the following situation for
~/default.aspx.

In file default.aspx:

<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false"
Inherits="Webproject1.default" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>default</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="default" method="post" runat="server">
<asp:Button id="Button1" runat="server" text="Button"
onclick="Button1_ClickHandler" />
</form>
</body>
</HTML>

In file default.aspx.cs:

namespace Webproject1
{
public class default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
...
protected void Button1_ClickHandler(object sender, System.EventArgs
e)
{
// Do something because the button was clicked
Button1.Text = "Clicked!";
}
}
}

All the codebehind classes of the web project are compiled together to
produce a single assembly, in this case, bin\Webproject1.dll. When
default.aspx is requested, ASP.NET parses it and compiles it into what I
called an "anonymous" class. Actually, it uses a name like ASPX_default.
This class is declared like:

public class ASPX_default : Webproject1.default
{
}

because of the "Inherits" clause in the Page directive.

So the "anonymous" class inherits the "named" class (Webproject1.default)
from Webproject1.dll, which in turn inherits System.Web.UI.Page from
System.Web.dll.

On a request, an instance of class ASPX_default is created. Various methods
of this class and of its base classes (especially, of the Page class) are
executed during the lifetime of the request, and the final output is sent to
the client. When all that's done, the instance of ASPX_default is destroyed.
The next time the page is requested, a new instance of the ASPX_default
class will be created. If the page has been cached, then the cached output
will be sent and no new instance will be created.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '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...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
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
2
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate...
9
by: John Smith | last post by:
Hi, I have this problem. I have a page class in code behind called "WebForm1" and I have another class called "Class1". Now in Class1 I am creating ImageButton and I am adding event handler...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
7
by: GaryDean | last post by:
In my old 1.1 apps the default was MS_POSITIONING="GridLayout" and Textboxes and labels and such always had POSITION: absolute; and I never had any distortion when the page was rendered. Life was...
1
by: rsteph | last post by:
I've got some product information pages, with images and text, all setup within a table. I'm trying to add a small image in the upper right hand corner of the content div (where all the important...
7
by: Andy B | last post by:
I have a class I am creating for data access. I need to access controls from inside the class that are on a particular page. How do I do this? or is creating an instance of the page class and using...
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?
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.