HighTechTalks DotNet Forums  

SetRenderDelegate() not firing into my code

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss SetRenderDelegate() not firing into my code in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rick Strahl \(MVP\)
 
Posts: n/a

Default SetRenderDelegate() not firing into my code - 05-28-2006 , 12:57 AM






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.SetRenderMethodDelegat e( 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



Reply With Quote
  #2  
Old   
Rick Strahl \(MVP\)
 
Posts: n/a

Default Re: SetRenderDelegate() not firing into my code - 05-28-2006 , 03:10 PM






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)" <rickstrahl (AT) hotmail (DOT) com> wrote

Quote:
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.SetRenderMethodDelegat e( 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





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.