I want to change some elements text when page is leaving the server (page_render, endRequest etc.).
How can i get access to the page and how can i find the elements to change their values, texts?
I want to change some elements text when page is leaving the server (page_render, endRequest etc.).
How can i get access to the page and how can i find the elements to change their values, texts?
You can do so by using a HttpModule. This sits in the pipeline and can do pre- and postprocessing.
For example take a look at this whitespaceremover.
Besides HttpModules, you can also override the 'Render' method (or do this in a basepage to make it reusable).
protected override void Render(HtmlTextWriter writer )
{
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
base.Render(htmlWriter);
string html = stringWriter.ToString();
// do stuff with the html
writer.Write(html);
}
There are a number of options and which one suites you will depend largely on what the actual goal is.
Here is a nice article Modifying the HTTP Response Using Filters