How to implement "PostRender" event for Controls

D

DC

Hi,

we need to dynamically load WebControls and WebUserControls and
manipulate the rendered output (before output fragment caching).
Actually, merely some static replacing of strings is required. And yes,
this requirement should not exist but it does.

We cannot overwrite the Render Method since our framework must support
all kinds of controls.

Is there a way to hook in after the Render method? I know this is
possible on a Page level (HttpModule) by manipulating the Response
Stream, but I guess this won't help since these replaces then have to
be exercised on every request no matter if the control uses caching or
not (?).

TIA for any hints!

Regards
DC
 
B

Brock Allen

Look into HttpResponse.Filter. It allows you to put your own Stream through
which the response is sent. Your filter then emits whatever it wants to.
 
D

DC

Thank you for the hint, Brock, and sorry for the late reply.

The problem of this approach is, that it will always intercept uncached
data and therefore imply quiet a performance hit.

However, I implemented an intercepting filter based on this approach
(here is a good article to get started on the topic:
http://www.awprofessional.com/articles/article.asp?p=25339&seqNum=3&rl=1)
and it works... so so.

One problem is, that one should actually manipulate the byte array
passed to the filter directly to get good performance
(Buffer.Blockcopy() and the like).

Another problem is, that the framework sends chunks of data to the
write method of the filter and it looks as if it is using "good" chunks
(i.e. the framework splits on </p> positions and the like) but it may
happen that one wants to replace data right at the edge between two
chunks and then a more complicated overflow method needs to be
implemented.

I am OK with my intercepting filter currently, but wanted to check if
someone know an alternative approach or a tailor made component for
this.

Cheers
DC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top