Introduction to ASP.NET Web Forms

In late 1990 ASP.NET was developed to enhance the Classic ASP framework and to enhance developer’s productivity by offering them a Rapid Application Development Frameworks. Visual Basic became quite popular amongst the developer because of its visual designer and editor. Now everyone can quickly design, code and test the application!

The Three main principles on which web forms are built are Page Post backs, View State and Server Control. They work as per the model shown below.

It can be clearly seen that every request to a web server for ASP.NET web form goes through a step of procedure before it is being rendered at the end users browser. Page Postback event is the main action that is called whenever a user requests a web form or raises an event.

To better understand the Web Form model, I am going to create a web form and place an ASP image button control. After that I have defined a click event in the code behind file.

<asp:ImageButton ID=”imgBtnBack” ImageUrl=”../ Icon/btnBack.gif” runat=”server” OnClick=”imgBtnBack_Click” /><asp:ImageButton

protected void imgBtnBack_Click(object sender, ImageClickEventArgs e)




When a user clicks on the image button, a page postback takes place, by postback I mean the same page is requested by the web server. At this point I would like to remind you that on a postback HTML pages looses their state because of its stateless nature.

But as far as ASP.NET Web Forms are considered you don’t need to worry about it because ASP.NET uses ViewState for persistency .When a user click the button ASP.NET Webform maps the ID of the button with the code behind event after that a page post back is fired and then the event mentioned above is fired. It seems quite simple in Windows programming where program state is persistent but it’s different with HTTP (Stateless protocol).It is all due to the web form model of ASP.NET that maintains the state of the page and events.

So what is a ViewState ,where does that come from?

ASP.NET WebForm model has a major pillar called ViewState whose job is to preserve the state of the page on every postbacks. ViewState is a form of dictionary that is maintained by ASP.NET WebForms on the client side and it is because of Viewstate that webforms have a persistent nature.

In the end I would like to explain about the third and last pillar of ASP.NET WebForms called Server Control s. By now you must have noticed in my code that I haven’t used html input field for a button control instead I have chosen to use ASP.NET Server Control called Image Button.

Server Control itself renders into plain HTML but it provides ASP.NET developers with a greater flexibility of using them in code behind files. The difference between a server control and a plain HTML control is the presence of runat attribute. By using Server Controls one can ignore getting into the unique HTML syntax and feature set. Server controls consume Viewstate information and implement postback events. In addition, server controls are responsible for producing markup and do that without strictly requiring strong HTML skills on your end.

That all folks , I hope it will serve helpful in understanding ASP.NET WebForm Basics.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s