The long awaited Active Server Pages .NET (ASP.NET) is the replacement for the current version of ASP. This key component of the new .NET framework has the potential to save organizations time and money by allowing them to establish object-oriented frameworks for the web applications. Microsoft has done an excellent job with automating common web development tasks, but more importantly they have created a tool that gives developers the ability to handle any business problem. In this first article of my transitioning to ASP.NET series, I will give you a basic overview of ASP.NET and server controls.
Big Picture, Little Picture
The arrival of new technology can always be confusing; however, one thing remains the same throughout all languages and platforms-"Fundamentals". I'm going to approach this series by focusing on what developers need to know to get their job done. I feel that the fundamental components of ASP.NET developers need to know are server controls, data access, .NET components, .NET classes, web services, debugging, IDE, how to access legacy ActiveX functions, and application performance. So lets get started!.
So what is the big deal about ASP.NET?
Although there are a lot of changes incorporated into ASP.NET, do not let people scare you into believing your current skills are not good enough. If anything your life will get a lot easier. The greatly improved ASP runtime handles a lot of routine tasks for you. Although there are other major benefits of ASP.NET, here are some that will benefit the majority of development shops.
Compiled Pages - A page is compiled into a .NET class the first time it is requested. The runtime engine will detect if any changes are made to the source code and recompile it if necessary. This should give your ASP pages a performance boost. You can optionally specify a class file with your page, if not the ASP runtime will create one for you.
More Scripting Choice - You can code your pages with Visual Basic, C#, or JScript. VBScript has been incorporated into the VB syntax.
Improved IDE and Debugger - No more Visual Interdev, the entire .NET family shares the same IDE and debugging tools. You will benefit greatly from the feature rich debugging tools for ASP.NET, it is a difference of night and day. The enhanced IDE is a joy to programming with.
Separation of Logic - Although you can currently separate business logic and presentation by utilizing ASP and COM. ASP.NET was designed with this concept in mind. It is a lot easier to encapsulate your logic from your presentation. In my opinion, application separation is the key to productivity. It allows you to maximize the abilities of your staff by assigning work accordingly. By creating .NET components and class files, you can maximize code re-use.
Backwards Compatibility - Organizations will be able to leverage their existing investments in COM and COM+. ASP.NET applications can interface with legacy COM objects.
So why should I make the switch?
Well my biggest reasons for converting to ASP.NET are encapsulation, inheritance, server controls, and ease of deployment. I enjoy the fact that ASP.NET pages are closely integrated with .NET classes. This offers me the ability to centralize application code within classes that have a smaller footprint than COM. These classes are easier to deploy and capable of deployment over distributed networks. With true inheritance, I can create base classes to maximize code.
As I mentioned earlier, I feel application separation is the key to developing quality applications. It allows your GUI designers to work on the GUI, code warriors to work on the classes and components, and database developers to create stored procedures and views. This ability gives the development manager options and flexibility within the development cycle. Just my 2 cents =)!
Anatomy of ASP.NET Page
I have constructed a very simple ASP.NET page to illustrate how very simple it is.
One new piece of code is the new <%@PAGE %> directive. It controls a lot of functionality for your page. One of the most useful is the ASPCOMPAT attribute, - this Boolean value determines if the page is backward compatible. You must set this attribute to true if you are calling legacy ActiveX DLL's.
These controls are basically server side .NET components. The four types of server controls are HTML, ASP, Validation, and User. This article will not focus on the user control, it will be covered in a separate article later.
These are your standard HTML controls with a few modifications that enable them to be used within ASP.NET. You can take any HTML control and add the ID and RUNAT attributes to make it a HTML server control.
Validation controls attach to input controls, they work together to provide developers with the ability to check required fields, patterns, ranges, and other routine validation scenarios.
<% @Page language="C#" %>
<form runat=server action="validate.aspx">
<asp:label id="lbltext" text="Type is a number greater than 10 "
<asp:Textbox id="txtnumber" runat="server" size="5" />
<asp:CompareValidator id="valtext" runat="server"
ForeColor="Red" ControlToValidate="txtnumber" Type="Integer"
ErrorMessage="Please enter a number greater than 10!" />
<asp:button type="submit" runat="server" id="btnsubmit"
text="Validate Me!" />
This article gave you a brief overview of the new ASP.NET framework. We will expand on this article in the following weeks to cover fundamental areas of ASP.NET. If you have any comments or questions regarding this article, please feel free to send me an e-mail.