Pages

13 June 2011

2.1.1)Importance of ViewState

View State in a mechanism used by ASP.NET to store  user specific and response data between pages request. The data being stored is typically associated with the server controls. This data is referred to as control state.

View state data is not stored by server but by a web page instead. More on (4.)

2.1.0) Life Cycle of ASP.NET Web Page.


Page Life Cycle events:

Init
InitComplete
PreLoad
Load
Control(PostBack)
LoadComplete
SaveStateComplete
Render


09 June 2011

2.0.0) Server Controls

Server controls are tags that are understood by the server.
This provides both functionality adn programmability through server side model eg:

<asp:control_name id="some_id" runat="server" />


All server control including web page itself , inherits from System.Web.UI.Control class.

 There are 2 primary types of server controls:
HTML and Web Controls.
HTML Control :  This provides server side processing that generally map back to HTML
Web Control:  These are ASP.NET controls that focus more on their object model and less on their HTML rendering.


Web server controls may render differently according to the browser .

07 June 2011

1.3.1) Web. Config File

WSAT : Website administration tool 

1.3.0) Web Configuration files(.config)

The configuration files allow management of settings to a site. These files are XML with .config as extension. Elements such as settings,database connection string, caching settings etc are included in this file.
A website may have more than one configuration files.

The configuration files are applied to site based on hierarchy. There is  a global configuration file on a given machine for all the sites called Machine.Config(%SystemRoot%\Microsoft.NET\Framework\<versionNumber>\CONFIG\directory)

The Machine.config file contains settings for .NET application types. Some settings may be overridden by Web.config.
The config file hierarchy :




06 June 2011

1.2.2) Website Compilation

Most applications are not precompiled. These pages and the codes are copied to the web server and then dynamically compiled by the web server the first time they are requested by a user. On compilation the code is placed inside an assembly and loaded into your site's application domain. Any user hence wanting the same page the same code will be served by the compiled assembly.

This is refereed to as a dynamic compilation.

1.2.1) The Anatomy Of ASPX

A tipical ASPX page include three sections: page derictives, code and page layout.

  1. Page directives: This section is used to set up the environment which specifies how the page should be processed.
  2. Code: This section contains code to handel the events that execute in the server based on the ASP.NET page processing model.(.cs for C# and .vb for Visual basic)(This may be in a seperate page or you can specify the code in the same page using the tag with the attribute runat="server".
  3. Page Layout: The Page layout is written using the HTML. This includes the HTML body, markup and the style information.
Example:
1)
<%@ Page Language="VB" %>
<"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--code-->
<script runat="server">
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Label1.Text = "Hello World!"
End Sub
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</div>
</form>
</body>
</html>
Single File VS Code- Behind Pages:
In single file model the compiler generates a new class for the page which inherits the Page Class.
The Code-Behind pages are physically separated from the user interface layout. This makes it easier to work with. The code is stored as a partial class that inherits from the Page class. Simplyfing the maintainance of the page as you do not have to keep page initialization information in a separate partial class as visual studio takes care of it.