Inheritance in ASP.Net using C#

liunx

Guest
Hi all,

I have make a base class which is used for handling all basic and initial subroutines. I have two abstract functions in this base class which request the child class to implement.

The problem come out now. Once the child class (which is an UserControl) extend this base class, it is no long be able to loaded in Web Forms designer of the Visual Studio 2003. A message box prompt that
=================================================
"the file could not be loaded into the Web Forms designer. Please correct the following error and then try loading it again:
Type Abstract
Make sure all of the classes usedin the page are built or referenced int he project."
================================================

Does anyone know why? Here attach the files for reference.

Kinsonyour making pure virutual abstract functions. Which is not really supported.

First of a class can only inherit 1 class. So you should use interfaces. Aslo, Formatting for language of a page should occur at differently, please look at RainBow Portals method of doing so.


Second off there is no need to create abstract class function definitions when they are pure vitural..

interface IMyInterface
{
string p{get;set;};

}

any class that uses that interface will be required to implement a version of that property.

If you implement the interface on another class and inherit the first class that also used it, then your still required to implement it.

a interface in C# is a contract. Meaning that all classes that inherit it, must also implement all methods publicly.Also you must inherit System.Web.Page class instead of WebControl.hi afterburn,

Thanks you reply. Where can I find the RainBow Portals method and what is it? Actually, I am required to creating multiple languages portals.

I have considered to use INTERFACE too, however, I have a concern that how can I enforce the child class to run "FormatPage" subrouteine when the page is loading. As I understand, INTERFACE is only storing the routine signature but not implementation, as a result, I cannot enforce them to execute it first. Am I correct? Do you have any suggestions?

KinsonYou create a class that your pages derive of. Usually refered to as Master Pages. You can search on how to do that. in the Master Page Class you call the function. The child class will aways construct any classes it derives of, so no need to worry about that.

You are correct it just adheres to the contract. However if you implement a class that inherits from it then you're ok.
 
Back
Top