How to implement "PostRender" event for Controls

Discussion in 'ASP .Net Building Controls' started by DC, Sep 26, 2005.

  1. DC

    DC Guest

    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
    DC, Sep 26, 2005
    #1
    1. Advertising

  2. DC

    Brock Allen Guest

    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.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > 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
    > D
    Brock Allen, Sep 26, 2005
    #2
    1. Advertising

  3. DC

    DC Guest

    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
    DC, Oct 11, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arulraja
    Replies:
    3
    Views:
    1,373
    William F. Robertson, Jr.
    Oct 17, 2003
  2. Davids
    Replies:
    3
    Views:
    390
    Eliyahu Goldin
    Dec 26, 2004
  3. snacktime
    Replies:
    11
    Views:
    210
    Robert Klemme
    Oct 13, 2005
  4. Cylix
    Replies:
    3
    Views:
    90
    Ian Collins
    Apr 3, 2007
  5. Owen Brunker
    Replies:
    7
    Views:
    124
    Owen Brunker
    Jul 20, 2007
Loading...

Share This Page