ace
ace

Reputation: 2161

How to modify raw HTML of ASP.NET page on PreRender?

I want to access the raw HTML code that my ASP.NET System.Web.UI.Page is about to render.

How can i do that? Is there a property or method like System.Web.UI.Page.HTML or something like that.

I know I could loop through the Controls List of the page and get access to all the Literal Controls etc, but I was wondering if there's a direct property or method that can return me the raw html, which I can modify just before rendering the page.

Upvotes: 3

Views: 2955

Answers (2)

JoeGeeky
JoeGeeky

Reputation: 3796

You can also use HTTPModules to make changes or just observe content inside the HTTP Pipeline. This would allow you to do things that are not necessarily the concern of the main application. Aside from providing additional layers for your application architecture, this can be handy for injecting changes after a product has gone to production since the main application itself does not necessarily have to be made aware of the changes (although that depends on which config you register the module in).

Upvotes: 1

John Saunders
John Saunders

Reputation: 161773

First of all, on PreRender, the page has not yet been Render'd, so there would be no HTML.

Second, look at the HttpResponse.Filter property.

Upvotes: 4

Related Questions