Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / May 2006

Tip: Looking for answers? Try searching our database.

SetRenderDelegate() not firing into my code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick Strahl (MVP) - 28 May 2006 05:57 GMT
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 ---

Signature

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

Rick Strahl (MVP) - 28 May 2006 20:10 GMT
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 ---

Signature

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

> Hi all,
>
[quoted text clipped - 32 lines]
>
> +++ Rick ---

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.