简体   繁体   中英

RadToolTip's RenderControl method

I have an asp.net application which uses the web part framework to allow users to customise their interface. One of the features of this is a catalog of available web parts, one is provided by default, but it can be overriden if you wish to change the layout, etc.

override void RenderCatalogPart(HtmlTextWriter writer, CatalogPart catalogPart)

That, as far as I can tell, is the only way to do it. At the moment I'm creating a panel with all the necessary elements in it, and using the panel's RenderControl method to output it to the htmlwriter. So far, so good. The problem occurs when I try to add a radtooltip to my panel, using the same RenderControl method, and I get the following runtime error:

Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.

I can see why this might be a problem, since the tooltip presumably uses javascript and has to write it to the page - but the RenderCatalogPart method has no knowledge of which page it's going to be outputting to. Is there any way around this or am I going to have to come up with an alternative?

I've posted this on the telerik website but though I'd ask here as well incase anyone has any ideas.

Thanks.

The Telerik ASP.NET controls require a MS AJAX ScriptManager control. I suppose that's why they want to access the page as well - to get a reference to the ScriptManager. Try setting the tooltip's RegisterWithScriptManager property to false and see if the control renders then.

The issue here is that the ToolTips must be created and added as controls in PreRender, so that it can add it's script to the ScriptManager.

Creating a collection of tooltips in the PreRender() method and then writing them to the httpwriter as shown above in RenderCatalogPart fixes the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM