Everything You Need to Know about ASP.NET Web Forms

ASP.NET Web Forms

h

In my last blog, I covered NuGet: an extension of Visual Studio that helps you integrate famous libraries and packages into your application. As I mentioned in that blog, I will be using NuGet from time to time throughout this blog series, so I went ahead and got it out of the way early. Now that you all know how to use that tool (if you don’t and haven’t read my previous blog, click here), I can start with the major technologies that are dominating the ASP.NET framework, helping us to build far better web applications than ever before.

In this blog I will be presenting to you the heart and soul of ASP.NET Technology. That’s right! The ASP.NET Web Forms that started it all. I remember starting ASP.NET 1.1 back in my university days. Ah, the golden days!

In this post you will find a brief introduction on ASP.NET Web Forms along with some details on how it works. We will then move on to practical implementation using the latest ASP.NET 4.5 Web Forms. The sections are clearly labelled (I hope) so you can find exactly what you need.

So without further ado ladies and gentlemen, ASP.NET Web Forms!

ASP.NET Web Forms

ASP.NET is an ever-growing technology for Web application development using the .NET Framework. It takes the best from its predecessor, Active Server Pages (ASP), as well as the rich services and features provided by the Common Language Runtime (CLR) then adds many new features. The result is a robust, scalable, and fast Web development experience that will give you incredible flexibility so you can develop web-based applications with ease.

What is ASP.NET Web Forms?

ASP.NET Web Forms is one of the three programming models for creating ASP.NET web sites and web applications using ASP.NET Technology with the .NET Framework. The other two programming models are ASP.NET Web Pages and ASP.NET MVC (Model-View-Controller), which I will be explaining in my coming blogs.

Web Forms is the oldest ASP.NET programming model. Web Forms are pages that are requested by end users using their browsers. These pages are written using a combination of HTML, server controls, and server code. The requested page is compiled and executed on the server and the response back is in the form of elements integrated in a neat structure with information that gives your Web applications their look and feel. This is known as a user interface (UI).

Visual Studio 2012 provides an incredibly powerful Integrated Development Environment (IDE) for you to create ASP.NET Web Forms. For example, it lets you drag and drop server controls to lay out your Web Forms page. You can then easily set properties, methods, and events for controls or for the page in order to define its behavior, look and feel, and so on. Now that we know what it is, let’s examine the different components that make up this awesome web development technology.

How does it work?

The Web Forms page is composed of 2 components:

  1. Aspx: Defines the visual aspect of the web page or UI.
  2. The code-behind file- Defines the behavior of the web page and controls used in it.

The aspx file usually contains HTML code along with some great Web Form server side controls that are pre-built and registered in Visual Studio that you can drag and drop onto the page. The HTML code and Web Form controls are stacked on the page in a neat structure that will become the final visual output of our web page. Client side code like JavaScript and Ajax controls/code can also be put into this file to help define client side behavior (like validations, etc. that don’t require a round trip to the server).

The code-behind file, sometimes known as the class file, helps define the behavior that the page will have through server-side processed code based on page lifecycle events like page_load, page_init and webform control events available to you on the web page that you added to the visual aspx file, like an ASP Button Control Click event or a ASP Dropdown Control Selected event.

When a user requests a page using his or her browser, these components are compiled on the server using IIS and the .NET framework (which includes ASP.NET assemblies) installed on that server. Then the server, along with any requested data from the database (if any) that is needed, returns the generated html output of the page as a response that is rendered by the browser along with the defined behavior it has on certain user interactions one can do on the page. An interaction on the page is when the code-behind file sends another request to be processed, carries out the defined behavior, and renders the desired html output of the page (see the figure below for a graphical representation of this process). For example: let’s say we have a web page that displays all the zip codes in the United States and I choose the option of selecting a city using a dropdown to filter those zip codes. I would set the behavior of that dropdown in such a way that it takes a trip back to the server to give it the selected city I choose, filter the zip codes on that city, and then return the filtered zip codes back to the page to display.


The following two tabs change content below.

Nasir Tariq

We are a collaborative company at Allshore Virtual Staffing, and encourage our employees to contribute content such as this.Allshore is a remote staffing agency helping startups in the U.S. hire remote software engineers to work as full-time employees. Allshore provides all technical and managerial support via our client services and technology mentorship teams based in Norman, Okla. Contact Allshore today to schedule a free consultation call with a remote staffing specialist or request a free trial of our services.

Latest posts by Nasir Tariq (see all)

  • A Practical Example of ASP.NET MVC - Mar
  • Everything You Need to Know About ASP.NET MVC - Mar
  • Everything You Need to Know about ASP.NET Web Forms - Dec

Pages: 1 2 3 4 5 6 7

Leave A Comment