Last post May 21, 2008 03:31 AM by Uwe82
May 21, 2008 03:31 AM|Uwe82|LINK
currently I'm developing an own framework for a CMS. For this, I have an abstract class "BaseControl" which inherits WebControl. This class is inherited by several Control classes, which display different things, such as pictures, text, a forum and so on.
A ContentManager class as another user control is placed on an aspx-page and dynamically creates the content elements.
The custom controls create HTML code and override the Render-method of the WebControl base class to output the HTML code via the HtmlWriter. What I need now, is a way, to wrap HTML code around each content element. So I gave the ContentManager a property
"ElementWrap". The BaseControl also gets a Wrap-Property which looks like "<div class="aclass">|</div>". The | should be replcaed with the output of the control itself.
So, and now the problem: I want to this to happen transparently in the BaseControl class, because I don't want to write the needed code for this in every Control-class, that I use. I found the methods RenderBeginTag and RenderEndTag, which I overrode, but
they seem to be called one after the other before the final Render-procedure. So the complete Wrap is printed before the content and not wrapped around it.
Another way would be, that I use my own Render-procedure, which I then override in the ancestor-classes, but some controls also just create custom user controls, which are added to their ChildCollection and rendered automatically by the WebControl methods.
And for this, this way would not work.
Any ideas on this problem?