Simple ASP.NET web control inheritance
-
Hello ... I have a really, really simple scenario which i can't accomplish. 1) I have a WebControl called "BaseControl". In that WebControl i just place a panel (100px x 100px) and turn it's backcolor to green. 2) I create a second control which inherits the BaseControl. However when i place that control the green panel is not displayed. I assume that the i can't inherit the html ? Is there a way i can do this ? Is there a way i can achieve that simple inheritance ... or a workaround ?
-
Hello ... I have a really, really simple scenario which i can't accomplish. 1) I have a WebControl called "BaseControl". In that WebControl i just place a panel (100px x 100px) and turn it's backcolor to green. 2) I create a second control which inherits the BaseControl. However when i place that control the green panel is not displayed. I assume that the i can't inherit the html ? Is there a way i can do this ? Is there a way i can achieve that simple inheritance ... or a workaround ?
You can inherit code, but not markup. If you want to have a hierarchical control model, you would need to design your base controls to use either manually rendered html with helper methods that inject html rendered from child controls, or use control compositing and helper methods that allow child controls to inject their own content.