Professional Web Applications Themes

Page class in ASP.NET - ASP.NET General

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 ...

  1. #1

    Default 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.........
    ozie Guest

  2. #2

    Default Re: Page class in ASP.NET

    > when is this Page class created ? Is it when the ASPX file 

    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.
     

    A class is an in-memory object. In special cirstances, classes can be
    serialized and stored in other media, but this is not typical.
     

    You can get the entire .Net SDK for free from Microsoft at the following
    URL:

    http://www.microsoft.com/downloads/details.aspx?FamilyId=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en

    --
    HTH,

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

    "ozie" <com> wrote in message
    news:01cf01c36c01$9ca17560$gbl... 


    Kevin Guest

  3. #3

    Default Re: Page class in ASP.NET

    "Kevin Spencer" <com> wrote in message
    news:phx.gbl... 
    >
    > 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[/ref]
    in 
    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
    com


    John Guest

  4. #4

    Default Re: Page class in ASP.NET

    John,

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


    "John Saunders" <com> wrote in message
    news:phx.gbl... 
    > >
    > > 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[/ref][/ref]
    cached [/ref]
    re-instantiate 
    > 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[/ref]
    of 


    MS Guest

  5. #5

    Default Re: Page class in ASP.NET

    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" <com> wrote in message
    news:phx.gbl... 
    > >
    > > 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[/ref][/ref]
    cached [/ref]
    re-instantiate 
    > 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[/ref]
    of 


    Kevin Guest

  6. #6

    Default Re: Page class in ASP.NET

    "MS News (MS ILM)" <com> wrote in message
    news:eXq$phx.gbl... 

    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 ps 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
    com


    John Guest

Similar Threads

  1. multiple form in a page class
    By Vanessa in forum PHP Development
    Replies: 2
    Last Post: May 21st, 08:55 AM
  2. Overiding Page Class
    By Vincent in forum ASP.NET General
    Replies: 2
    Last Post: August 27th, 03:52 AM
  3. Replies: 0
    Last Post: August 18th, 04:34 PM
  4. Referencing Custom Page Class within a Control
    By William F. Robertson, Jr. in forum ASP.NET General
    Replies: 1
    Last Post: July 10th, 08:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139