June 15, 2002

OK, Let's talk a little bit about ASP.NET and some of the techniques that make .NET the rave on the Web.

One of the great things about the .NET framework is that it supports numerous languages. Most enterprise-wide solutions involve different schools of thought, anything from JAVA to simple HTML. Microsoft's .NET provides functionality for all of the players in the solution to work on their own part of the project at their own pace, and simultaneously. The .NET framework provides "code-behind" functionality - meaning, an application has code behind it working side-by-side with other code. So you may ask yourself... "What does this mean for me?" It means that if you are an HTML designer working on a wire-frame for a Web application, you do not have to wait for the JAVA developers to finish their part before you can work on yours, and vice versa. Everyone can work in parallel as the framework only compiles their specific work and not the whole solution, unless need be.

Secondly, the .NET framwork adds very robust cacheing to the delivering Web servers. When an application is called by a visitor from the web site, it will stay in memory until it needs to be flushed out for a different application. You can see this in action on this simple ASP.NET page, http://www27.brinkster.com/owlick/dotnet/something.aspx.
This page utilizes a feature called "postback form". This means the page is both responsible for displaying the results of the application and processing the the data input by the user.
Because of this, 2 pages are no longer needed for simple form processing. The submitting of the form posts the information to itself via reload, and the HTML is rendered accordingly.

This does not mean that you cannot have an ACTION property. It is just as easy to redirect the user upon submit to another .aspx page for processing. We will stick to the postback topic for now.

Let's take a look at the code for the something.aspx: http://www.randompsycho.org/owlick/dotnet/something.aspx.txt.

The first line: shows the language used as Visual Basic - script language="vb"; and the attribute of runat="server". The language is your preference. Microsoft is pushing C# as the primary language and if you have other object-orientated language experience such as C++ or JAVA you can pick the C# language up fairly easily. I prefer VB.NET as I have experience in Visual Basic.

The second line: starts the Subroutine called Page_Load with the basic variables needed for any .NET application (sender As Object, e As EventArgs). We will not get into this part in depth as the focus of this topic is the ASP.NET page and postback feature and not the rudimentaries of the .NET framework. But to let you know, it is the event for creating an event handler and is most commonly used. When the Page_Load is fired a view state is created and then you can access the Web controls for this particular page.

Third line: comments about the process performed. NOTE: Comments in an application rule! Please use them. It is good practice to do so and helps other troubleshoot your application.

Fourth line: The infamous Response.Write part of ASP. This returns the value entered into the textbox of the form.

Fifth line: Ends the Subroutine.

The next few lines are basic HTML with some added features. You will notice that in the form there are Web controls which you are probably not used to seeing in HTML or traditional ASP. The runat="server" makes the form server-side and secure. The textbox becomes a Web control as and is also run at the server. Make sure you give it an ID as it is what the Response.Write will get for its information. The button also has become a Web control and is run at the server.

Simple form here, but the main issue at hand is... when you run this form you will notice that the speed of which the form processes is instantaneous upon submit. There is NO round trip back to the server for processing. It is handled here, via postback! Cacheing allows for this :) It is a server admin dream and creates a better user experience.

Next time: More postback features and responding to postback form and checking to see if the form has already been posted back.