Advantages of Base Application Page

Learn how to how to extend Base Application Pages to make global control changes and eliminate error-prone, repetitive coding.
- Akesh Gupta of Light Speed Solutions

August 4, 2009
Iron Speed Designer V6.X

Introduction

Iron Speed Designer creates a sub-class of the .NET Framework Page class and uses it as the class from which all generated pages are derived.

All Page classes in your application derive from the BasePage class.

The BasePage extends the default Page class of the Microsoft .NET Framework classes. All ASPX files created by Iron Speed Designer are derived from the BasePage class.

The application classes extend the .NET Framework to support applications generated by Iron Speed Designer. Applications generated by Iron Speed Designer use classes inherited from other application classes and .NET Framework classes.

Application classes are generally derived from .NET Framework classes.

For example, the default page class used by .NET is System.Web.UI.Page. This class is sub-classed in application classes as BasePage. Applications use this class to generate individual pages.

The purpose of application classes is twofold. First, application classes provide extensions to the Microsoft .NET Framework to deliver additional functionality. Second, they enable you to add features that apply to the entire application by making changes to these classes.

Iron Speed Designer makes use of Base Application Page (part of Generated Application Classes) as a base to every page generated in the application. This allows a user to write more generic code in the Base Application Page instead of repeating the code on every page.

The Base Application Page exists under the shared folder in the App_Code folder for each Iron Speed Designer application.


The advantages are obvious: you only have to write the code in one place, and every page inherits it automatically. Iron Speed Designer Code Customization “Application Wide Page Security” generates the code in a Base Application Page, which in turn makes every page check for security. Thus, even if you create 1000 pages in your application, your security is checked at one place. It is possible to implement your custom security model for each page with some metadata configuration.

Solution

There are several other solutions you can implement on the Base Application Page.

For example, if your customer wants to see which fields are required when they open the Add or Edit page in Iron Speed Designer applications. Assign an asterisk (*) indicator against each required fields label or use color coordination. These options require manual processes and are prone to errors.

Iron Speed Designer has required field validators. These check whether the field is required as a link for your solution. This ensures Client Side Validation has all required fields completed before any page can be submitted.


Establish a list of validators on a page and set the IsValid property to False at startup. The page will display validators as an asterisk against each required field. Or implement this login in the Base Application Page - Pre Render event.

ASP.NET has a built-in function called Page.GetValidators that returns the list of all the validators (as a validators collection) on a page.

An example of Pre Render Override on Base Application Page follows:


All the validators will show a “*” by every required field when the page loads.

You can also change the Validator Text from “*” to “Is Required” or “!” globally without changing each field manually.


As shown above, we have replaced the default “*” with “!” as a hyperlink to a central help site with the parameter of the field to validate.

Conclusion

Iron Speed Designer’s application hierarchy uses base controls extensively to eliminate error-prone, repetitive coding. Now you understand how to extend Base Application Pages to make global control changes.

About the Author

Master of Sciences – Northwestern University
MCSE+I, MCSD, MCDBA, MCT

Akesh is co-founder of Light Speed Solutions and ExecuTrain of Long Island. He is passionate about technology and loves to share his knowledge with others. ExecuTrain of Long Island is a corporate training company specializing in bringing real world knowledge to the training room. Light Speed Solutions is a professional consulting and software development company that focuses on turning business vision into reality. Akesh Gupta has more than 14 years of experience in architecting, designing and developing successful applications. Light Speed Solutions has become a one-stop solutions center offering advanced, diversified expertise in all facets of development, with complementary expertise in systems, reporting and accounting. Akesh holds a Master of Sciences degree from Northwestern University.



  Privacy Statement