maybe its just me again, but can't you
protected override void Render(HtmlTextWriter writer)
{
TextWriter myTextWriter = new StringWriter();
HtmlTextWriter myWriter = new HtmlTextWriter(myTextWriter);
base.Render( myWriter);
string html =myWriter.ToString();
html = html.Replace("foo", "bar");
writer.Write(html);
}
I'll try this tomorrow (when I'm at the client's site again), but I suspect that I'm going to get double output. "base.Render" and "writer.Write" are both going to output to the response stream.
The content gets added to the response stream later. The content that is building up is the writer part in Render(HtmlTextWriter writer)
Since we add to another writer, and only add once to the writer its ok :)
You need to attach a StringBuilder to the StringWriter and string html = stringBuilder.ToString(), otherwise the output will be pretty boring.. :)
And this works for us btw, when overriding OnRender in a UserControl or ASPX.
Anders -- you had it (almost, see below).
The thing I missed in your code is that you're creating a "local" HtmlTextWriter, rendering to that, then grabbing the HTML out of it.
The only change is what I think Erik was hinting at above: myWriter.ToString() just returns the class name. I did this:
myWriter.InnerWriter.ToString()
This gave me the underlying HTML.
I have a control adapter that does some manipulation on EPiServer properties. It's declared like this:
public class EPiServerContentFilter : PropertyDataControlAdapter
I override the Render method, and do some stuff, like this:
This works fine, with one exception: dynamic content does not execute.
When I just call this --
-- it works fine.
I had this same problem when extending the Property control. I posted about that, but then figured out that I needed to do was call "EnsurePropertyControlsCreated()" which is a method on the base Property class.
However, I can't get at this method inside the adapter. The adapter as a "Control" property and a "PropertyDataControl" property, neither of which can be cast into "Property."
Ted Nyberg had a good post about manually parsing a control with dynamic content. The trick to that seemed to be calling "SetupControl" on the PropertyLongString class. I tried it, but it still didn't work.
So, how do you get dynamic content to execute when you're manipulating the XHTML property via an adapter?