SetRenderDelegate() not firing into my code

  • Thread starter Rick Strahl \(MVP\)
  • Start date
R

Rick Strahl \(MVP\)

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
 
R

Rick Strahl \(MVP\)

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
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top