user controls design question

  • Thread starter Thread starter sonic
  • Start date Start date
S

sonic

Hello,
I am trying to create a custom control hierarchy that encapsulates web
controls in my framework and run into a interesting problem.

my framework will automatically save all user control
values/preferences and initiate them from query string. My framework
will provide all necessary work and all the developers will have to do
is:
<myCo:CustomTextbox id="myText" runat="server" />
or
<myCo:CustomDropDown id="myDropDown" runat="server" />
and everything will be handled.

to achieve this, all of my controls would inherit from
CustomBaseControl which inherits WebControl, and adds additional
methods/events for improved personalization etc..

it works great, accept the web control strong typing is lost during the
declaration of the custom controls since they all inherit webcontrol.

so i cannot do
<myCo:CustomTextBox id="myText" runat="server" Text="this will berak"
/>

since c# does not support multiple inheritance, i have a choice of
inheriting from TextBox, and my own interface which would ensure that
all custom controls would implement necessary methods/event, or
inheriting from baseclass which will provide all of my controls with
common functionality, and running into the problem above.

any thoughts ?
 
AFAIK you're lost on this. I also strongly suggest .NET to support multiple
inheritance.

Currently all you can do is to not derive from your base class but instead
derive e.g. from asp:TextBox and to add a single custom interface to your
class library plus a base class implementing your features and then
implement the interface using stub functions in your derived class
(=aggregation) to call the base class's function... *yuk*

HTH,
Axel Dahmen
 
yeah..
so what about exposing the underlying type.
if i inherit from MyCustomControl and that control handles all common
functionality, than inside of there, is generate the actual TextBox
control and render it manually.
If i expose that control developers could still access it on codebehind
files by:
((TextBox)myText.RenderedControl).Size = 20;
is it possible to do this in aspx page ?
something like:
<myCo:MyTextBox id="..." id="myText" RenderedControl-Size="30" />
etc..
would i have to do anything special to achieve this?
 
how would you want to do the casting if you can't derive from it? If you're
deriving from Control you can't assign some constructor argument (or
whatever) to yourself...

nono... unfortunately this doesn't work... *sigh*


------------
 
Back
Top