SetRenderDelegate() not firing into my code

Discussion in 'ASP .Net Building Controls' started by Rick Strahl \(MVP\), May 28, 2006.

  1. Hi all,

    I'm working on a control that has to inject some markup into another control
    at the end of rendering. I'm trying to use SetRenderMethodDelegate() to make
    this happen.

    Unfortunately I can't seem to get this to work.

    BindingItem.ControlInstance.SetRenderMethodDelegate( new
    RenderMethod(BindingItem.RenderBindingErrorMessage) );


    This code fires just fine, but the delegated pointed to never fires, when
    rendering time comes. Instead the control just renders as usual with stock
    rendering.

    The above call to SetRenderDelegate is called typically from page processing
    code (ie. Page_Load or a specific event), so it shouldn't be too late to
    hook up here. BindingItem is local reference passed by parameter, but its
    lifetime is page level (Collection item of a Page Control).

    Frankly I'm not sure what to check further. The assignment works without
    error so the delegate is correct and the signature should be OK. But the
    delegate simply is not fired.

    Anybody have any idea of why this wouldn't be working?

    Along the same lines, can anybody think of another way to inject markup into
    another control? I've arrived here mainly because of issues related to <%=
    %> tags in the page making it impossible (ok difficult) to use Control.Add
    to add controls dynamically (http://west-wind.com/weblog/posts/5758.aspx)

    Any ideas appreciated...

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    www.west-wind.com
    www.west-wind.com/weblog
     
    Rick Strahl \(MVP\), May 28, 2006
    #1
    1. Advertising

  2. Ok I figured out that SetRenderDelegate only fires on container controls. It
    wasn't going to help with what I needed to do here anyway as it only lets
    you inject content into the control body, so this wouldn't really work for
    say adding some markup after a TextBox or label.

    So, anybody have any idea how to do this reliably? I need to inject controls
    or markup after a control has rendered from an external control (a page
    level extender).

    It really seems a shame that there's no mechanism to hook a control's Render
    method to create post or pre control markup. This would be a highly useful
    feature for many things. If only Control.Add() would work reliably in all
    pages regardless of <%= %> scripts in the page this wouldn't be an issue.

    Grrr... <g>

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    www.west-wind.com
    www.west-wind.com/weblog



    "Rick Strahl (MVP)" <> wrote in message
    news:...
    > Hi all,
    >
    > I'm working on a control that has to inject some markup into another
    > control at the end of rendering. I'm trying to use
    > SetRenderMethodDelegate() to make this happen.
    >
    > Unfortunately I can't seem to get this to work.
    >
    > BindingItem.ControlInstance.SetRenderMethodDelegate( new
    > RenderMethod(BindingItem.RenderBindingErrorMessage) );
    >
    >
    > This code fires just fine, but the delegated pointed to never fires, when
    > rendering time comes. Instead the control just renders as usual with stock
    > rendering.
    >
    > The above call to SetRenderDelegate is called typically from page
    > processing code (ie. Page_Load or a specific event), so it shouldn't be
    > too late to hook up here. BindingItem is local reference passed by
    > parameter, but its lifetime is page level (Collection item of a Page
    > Control).
    >
    > Frankly I'm not sure what to check further. The assignment works without
    > error so the delegate is correct and the signature should be OK. But the
    > delegate simply is not fired.
    >
    > Anybody have any idea of why this wouldn't be working?
    >
    > Along the same lines, can anybody think of another way to inject markup
    > into another control? I've arrived here mainly because of issues related
    > to <%= %> tags in the page making it impossible (ok difficult) to use
    > Control.Add to add controls dynamically
    > (http://west-wind.com/weblog/posts/5758.aspx)
    >
    > Any ideas appreciated...
    >
    > +++ Rick ---
    >
    > --
    >
    > Rick Strahl
    > West Wind Technologies
    > www.west-wind.com
    > www.west-wind.com/weblog
    >
    >
     
    Rick Strahl \(MVP\), May 28, 2006
    #2
    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. Ken Tucker
    Replies:
    2
    Views:
    2,564
    Ken Tucker
    Jul 6, 2003
  2. Replies:
    3
    Views:
    1,989
  3. Eric Sabine

    code on button not firing on click

    Eric Sabine, Jun 3, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    331
    Janaka
    Jun 3, 2004
  4. Replies:
    1
    Views:
    720
    Norman Yuan
    Mar 22, 2007
  5. MDW

    ASP.Net Code Not Firing

    MDW, Apr 23, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    344
    Juan T. Llibre
    Apr 23, 2008
Loading...

Share This Page