This is a tricky situation.The kind that we turn to runestones to unravel.
Problem – You can create a base User Control in a Windows Form project. Then, you can create another User Control that is inherited from the first quite easily by choosing Add New Item/Inherited User Control from your Solution Explorer (right click your project to get this menu). You cannot do the same for a Web User Control.
Now, why do you want to do this? Well, you’ll want to do this for the same reason you’ll want to create a base class in any other situation – you may wish to embed commonly used attributes and methods into the base class. Then, when you create sub-classes that inherit from it, you only need to write codes for pieces of specialized work that differ from the common functionalities.
Solution – The solution is actually quite simple. Follow these steps –
- Create your base class in the App_Code folder (right-click App_Code folder, select to create a Class)
- Ensure that your base class is implemented inside a namespace (begin the class declaration with a namespace.. statement and end it with an ..end namespace statement)
- Create your sub class and inherit it from the base class (assuming that your sub-class is a visible Web User Control for a DotNetNuke module, right-click on the DesktopModules folder, then select to create a new Web User Control. After it has opened, modify the Class declaration code for the new We User Control by changing the … inherits clause).
I got this solution from a response to a question.