I’ve recently returned from the 2000 Microsoft Professional Developer’s Conference, and am really excited. The technology that Microsoft has developed to allow Web developers to create richer and more robust applications in less time than ever, is going to powerfully impact Internet applications in the future. The technology I’m referring to is the next generation Active Server Pages (ASP), now known as ASP+.
How does ASP+ make your job easier and allow you to create better applications? In short, ASP+ gives you some nice tools that make development easier and more powerful. They include compilation, additional language support, Web Forms, and Server Controls.
In this article, I’ll briefly talk about what I feel are the high points of the ASP+ technology. In later articles, I’ll drill down to the details and give you what you need to use the technology in your applications.
ASP+ Pages are Compiled
ASP+ files are still the easy-to-edit text files that they always have been. You can use Visual Interdev or Visual Studio 7 to manage ASP+ projects. But of course, you can also use everyone’s favorite editor: Notepad.
ASP+ creates a ghost copy of the source file that’s compiled. The compiled code executes much faster than the original ASP interpreted .asp files. And any time you make a change to the ASP+ source files, Internet Information Server (IIS) recompiles it when it gets another request for the changed file. This type of on-demand compilation is known as Just-In-Time (JIT) compilation.
Implementing JIT for ASP+ is a two edged sword. Yes, the compiled code is faster. But don’t wait until you demo an application for your boss or a client to allow it to compile. That’s because the application will slow down very noticeably the first time it runs while the updated source files compile.
By the way, the new file extension for ASP+ source files is .aspx. And the new name for the Global.asa file is Global.asax.
Additional Language Support
My background is Visual C++. For this reason, I spent more than my fair share of time learning VBScript for ASP programming. ASP+ adds a new object-oriented language named C#. It’s similar to Visual C++ in a lot of ways, and also shares some similarities with Java. As a matter of fact, I feel that it’s closer to Java than Visual C++.
C# has an added advantage in that its design includes features that easily allow developers to create and use COM+ components. For more information, check put the C# articles on www.sourceDNA.com.
Web Forms Offer Easy Control
ASP+ Web Forms Page offer a programming model that can be used on the server to dynamically generate web pages. Intended as a logical evolution of ASP (ASP+ provides syntax compatibility with existing pages), the ASP+ Web Forms has been specifically designed to address a number of key deficiencies with the previous model. In particular:
- The ability to create and use reusable UI controls that can encapsulate common functionality and reduce the code a page developer has to write.
- The ability for developers to cleanly structure their page logic in an orderly — non-"spaghetti code" – fashion.
- The ability for development/authoring tools to provide strong WYSIWYG design support for pages (existing ASP code today is opaque to a tool).
ASP+ Pages provides syntax compatibility with existing ASP Pages. This includes support for <% %> code render blocks that can be intermixed with HTML content within a .aspx file. These code blocks execute in a top-down manner at page render time.
While <% %> code blocks provide a powerful way to custom manipulate the text output returned from a ASP+ Page, they do not provide much help in providing a clean HTML programming model. Developers using only <% %> code blocks must custom manage page state between round-trips and custom interpret posted values.
ASP+ Web Forms Page provides a set of validation server controls that provide an easy-to-use but powerful way to check input forms for errors, and if necessary, display messages to the user.
Validation controls are added to a ASP+ Page like other server controls (discussed a little later). There are controls for specific types of validation, such as range checking or pattern matching, plus a RequiredFieldValidator that ensures a user does not skip an entry field.
ASP+ Page developers can optionally check the Page.IsValid property at runtime to determine whether all validation server controls on a page are currently valid. This provides a simple "one line" way to determine whether or not to proceed with business logic. For example, the below sample performs a Page.IsValid check before executing a database lookup on the selected category:
Controls Provide Reusability
In addition to (or instead of) using <% %> code blocks to program dynamic content, ASP+ Page developers can now leverage ASP+ Server Controls to program web pages. Server controls are declared within a .aspx file using custom tags that contain a runat="server" attribute value.
The below sample uses four server controls: <form runat=server>, <asp:textbox runat=server>, <asp:dropdownlist runat=server>, and <asp:button runat=server>. At runtime these server controls automatically generate HTML content. Using the four server controls mentioned above.
<%@ Page Language="C#"%> <html> <head> <link rel="stylesheet"href="intro.css"> </head> <body> <center> <form action="intro4.aspx" method="post" runat=server> <h3> Name: <asp:textbox id="Name" runat="server"/> Category: <asp:dropdownlist id="Category" runat=server> <asp:listitem>psychology</asp:listitem> <asp:listitem>business</asp:listitem> <asp:listitem>popular_comp</asp:listitem> </asp:dropdownlist> <asp:button text="Lookup" runat="server"/> </form> </center> </body> </html>
These server controls automatically maintain any client-entered values between round-trips to the server. This control state is not stored on the server (it is instead stored within a <hidden> form field that is round-tripped between requests). Note also that no client-side script was required on the client.
In addition to standard HTML input controls, ASP+ enables developers to utilize richer custom controls on their pages.
About the author:Richard Leinecker is a noted author and trainer.