I'm creating an 'extended Text Box' and I'm adding a 'required' property, which if set to 'true' will add a . They share some common properties and methods, for example I have an Add Required Field Validator method that uses some of the extended properties I've added.

validating custom control attributes-78

As I can't use true multiple inheritance in C#, how would I design this to be able to share the methods and properties?

If I specify the expected type being passed into 'standard' methods as 'Web Control' it doesn't work as the extended controls have the additional properties.

they inherit from Text Box, Radio Button List and so on).

I also can't just pass the extended web control objects as a parameter into the shared methods as the extended controls are of different types (e.g. To use these, add this declaration to the aspx page: using System; using System.

To achieve this I've implemented an interface that defines the additional shared properties, and am using it like this: public interface IExtendend Control { string Required Message { get; set; } string Validator Css Class { get; set; } bool Client Script { get; set; } Required Field Validator rfv { get; set; } } public static class Extended Control Extensions : IExtendend Control { public static void Add Required Field Validator(this IExtendend Control control) { = new Required Field Validator(); Required Message; Configure And Add Validator(control, control.rfv); } public static void Configure And Add Validator(this IExtendend Control control, Base Validator validator) { validator.

So I tried adding a base class that inherits from Web Control and implements the interface, like this: public interface IExtendend Control { string Required Message { get; set; } string Validator Css Class { get; set; } bool Client Script { get; set; } Required Field Validator rfv { get; set; } } public class Base Extended Control : Web Control, IExtendend Control { public string Required Message { get; set; } public string Validator Css Class { get; set; } public bool Client Script { get { return Client Script = true; } set { } } public Required Field Validator rfv { get { return rfv = new Required Field Validator(); } set { } } } public static class Extended Control Helper : IExtendend Control { public static void Add Required Field Validator(this Base Extended Control control) { Base Extended Control extended Control = (Base Extended Control)control; extended = new Required Field Validator(); extended Required Message; Configure And Add Validator(control, extended Control.rfv); } public static void Configure And Add Validator(this Base Extended Control control, Base Validator validator) { validator.

Add(validator); } } Trouble is that the 'Configure And Add Validator' method now doesn't know anything about the 'ID' or 'Client Script' properties of the control since 'IExtended Control' only defines the custom properties, not the standard properties of a web control.

The trouble now is that in my extended Text Box class I can't cast my extended Text Box as a 'Base Extended Control' to use the extension methods, as the extended Text Box inherits from the standard Text Box class like this: public static class Extended Control Helper { public static void Add Required Field Validator(this IExtended Control control) { = new Required Field Validator(); Required Message; Configure And Add Validator(control, control.rfv); } public static void Configure And Add Validator(this IExtended Control control, Base Validator validator) { validator.

Add(validator); } } The trouble now is that in my extended Text Box class I can't cast my extended Text Box as a 'Base Extended Control' to use the extension methods, as the extended Text Box inherits from the standard Text Box class like this: so there's no common base to cast Extended Text Box as 'Base Extended Control' as it doesn't inherit from it. Fuex - you put me on the right track, here's the final code which includes an a extended Text Box control and extended Radio Button List control.