Today's Thought

If men could regard the events of their own lives
with more open minds, they would frequently discover
that they did not really desire the things they failed to obtain

Friday, August 19, 2011

The Code-Behind Page Model:

  • HTML markup are kept in one file and the programming code in another file.
  • There are two differences in the .aspx page between the single-file and the code-behind models:
    • In the code-behind model, there is no <script> block with the runat="server" attribute.
    • In the code-behind model, the @Page directive contains attributes that reference an external file and a class.
  • The code file contains a partial class, which indicates that the class contains only some of the total code that makes up the full class for the page.  
  • The partial class inherits from a base Page class (either System.Web.UI.Page or a class derived from System.Web.UI.Page). 
  • The .aspx file contains an Inherits attribute that points to the code-behind partial class.
  •  When the page is compiled, ASP.NET creates a new partial class for the .aspx file. This class is a peer of the code-behind partial class file and contains the declarations for the page’s controls.
  • Finally, ASP.NET generates a class that inherits from the partial class created from the .aspx file and the code-behind partial class.
  • The generated class is compiled into an assembly that runs in order to render output to the browser.

No comments:

Post a Comment