Posted by: savagerider | August 26, 2007

ASP.NET Web Form

Web Form split between client side interface and server side code. When user requests a page, only client side interface will be sent to the browser. This is different from the conventional html where it will send everything to the browser.

.aspx : Web form
.aspx.cs : Code-behind page for server code

There are 3 levels of attributes in a page:

  •  Page attributes

it consists of the smartNavigation, language used and code-behind file name

  • Body attributes

it consists of pageLayout [Flow layout/Grid layout]

  • Form attributes

It consists of method [Get/Post] and Runat, which indicate posting control information back to asp.net page on the server. Without runat, it behaves like normal web page, where it posts to server for processing not code-behind page.

Server control

1. These are the components that run on the server which include UI and other functionality. It comes with runat=”server” properties for each server component. This also shows that the logic in the control is executed on the asp.net server side but not on the browser (client side).

2. These components enable view state, which saves user input of the control when the page is sent back. HTML control does not save anything when the page is returned from the server to the client. In short, you will see what you keyed in after you click submit for server component.

“<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>”

html controls VS Server controls

html controls does not run on server they only run on client browser.

Web server rendered asp.net for client browser, depending on the browser version and features supported. If the client browser does not support certrain client scripts, asp.net server will use one more trip to generate server side script to achieve the objective.

Adding runat=”server” can convert html controls to asp.net server controls.

Server control cannot be function properly if runat=”server” is missing.

Different types of buttons

1. HTML button

2. HTML server control button

3. Web Server Control button

For item 1, it can only trigger client side events, whereas item 2 and 3 can raise server side events. After adding runat =”server” to item1, it will transform to item2.

Comparatively, it is adviserable to use web server controls instead of html controls if there is no bandwidth limitation. 

Types of web server controls:

  • Intrinsic controls
html controls with runat=”server” attribute
  • Validation controls
A set of controls which has the logic to validate input
  • Rich controls
Complex controls that provide multiple functions like calendar control and Adrotator
  • List-Bound controls
A set of controls that allow you to display a lists of data with reformatting, sorting and editing data, which include dataGrid, checkBoxList, dropDownList and ListBox
  • IE Web controls 
Complex controls such as treeview, tabstrip, toolbar and multipage controls

HTTP is stateless protocol

It is possible to use VIEWSTATE to keep track on the state in asp.net web form. When runat=”server” is added, VIEWSTATE information is added to the page. This implementation facilitates the web farm architecture where the page is not necessary to be routed to the same server and the VIEWSTATE information is stored in the page instead of the application web server.

To maximise the performance, it is advisable to disable the viewstate on the page level and enable it on controls level, with EnableViewState attribute


Leave a response

Your response:

Categories