Developing an ASP.NET Framework From a Windows Forms .NET Perspective.

A couple of months ago, I had to quickly develop an ASP.NET framework.
I incorporated parts of a Windows .NET framework that I had previously worked on. The basic
premise being that a Windows .NET Form and an ASP.NET WebForm are both event driven 
and have controls such as buttons and dropdowns.

There were two basic steps in developing this ASP.NET framework.

1) Creating Ancestor code behind pages for all the code behind pages used in the project: 

a) public class WebFormBase : System.Web.UI.Page -> For the Web Forms
b) public class WebUserControlBase : System.Web.UI.UserControl   -> For the Web User Controls
When a Webform or Web UserControl needs to be created, their code behinds inherit from the custom base class:

public class  OrderWebForm : WebFormBase
public class  ProductWebuserControl : WebUserControlBase

I think the above is a pretty standard thing to do.

The only thing I really did a little bit differently was to raise more events up to the descendent pages such as:





In this way the descendent code has a chance to do some work before and after the code in ancestor.

2) All server side controls used on a WebForm or Web UserControl are inherited from the standard Microsoft Web Controls, or a third party control:

public class MyWebButton : System.Web.UI.WebControls.Button
public class MyWebMenu : Infragistics.Web.UI.UltraWebMenu
etc. etc. As you know there are many more. Hyperlink, Label, DataList etc.

For this framework thats pretty well it, in a nutshell.

This has really paid off for the future development work, because server Side controls can now implement custom interfaces,
such as :

Then in the base classes for the code behind for the WebFormBase or the WebUserControlBase, all the code is there to handle translation  of pages to French or English or to disable or enable or disable controls automatically depending on a custom property put on the Web page called Enabled. Other things that have been built into the framework are resource file management, session management, navigation management and a custom help button that launches another browser with some help.