Making a page’s base class an abstract class.

In the normal code-behind technique, your page inherits from this regular class you create as the code-behind class.  I’m implementing a template feature in my project, and most templates will be just markup without code, so there is no need for a code-behind class; however, I wanted to make sure every template implemented two properties, so I thought, “I’ll use an abstract class”.  I created an abstract class and inherited my pages from it.  It worked great, but I had a problem with the VS.NET designer.  I can view the Template page in the designer because “the designer can’t create an instance of an abstract class”.  Then I thought, “what benefit am I getting by making this base class abstract?  Not much.  If I make it a regular class, I can implement virtual, default values.  So that’s what I did.


Lesson learned:  Code-behind classes need to be non-abstract so the designer can function properly.