I have a page that has a bunch of user controls on it. I want to be able to have "macros" or "placeholders" directly in the content that will get replaced in my code. It shouldn't really matter, but I'm using Ektron as my CMS.
Are there any page events that I can hook into to do a string replace on the entire rendered page content, right before it's sent to the client?
UPDATE
Here is the code that I am currently using to accomplish this:
protected override void Render(HtmlTextWriter writer)
{
string content = string.Empty;
using (var stringWriter = new StringWriter())
using (var htmlWriter = new HtmlTextWriter(stringWriter))
{
// render the current page content to our temp writer
base.Render(htmlWriter);
htmlWriter.Close();
// get the content
content = stringWriter.ToString();
}
// replace our placeholders
string newContent = content.Replace("$placeholder1$", "placeholder1 data").Replace("$placeholder2$", "placeholder2 data");
// write the new html to the page
writer.Write(newContent);
}