RadToolTip 的 RenderControl 方法

发布于 2024-12-27 13:36:07 字数 592 浏览 3 评论 0原文

我有一个 ASP.NET 应用程序,它使用 Web 部件框架来允许用户自定义其界面。其功能之一是可用 Web 部件的目录,默认情况下提供一个目录,但如果您希望更改布局等,则可以覆盖它。

override void RenderCatalogPart(HtmlTextWriter writer, CatalogPart catalogPart)

据我所知,这是唯一的方法它。目前,我正在创建一个包含所有必要元素的面板,并使用面板的 RenderControl 方法将其输出到 htmlwriter。到目前为止,一切都很好。当我尝试使用相同的 RenderControl 方法将 radtooltip 添加到面板时,会出现问题,并且出现以下运行时错误:

页面不能为空。请确保此操作是在 ASP.NET 请求的上下文中执行的。

我明白为什么这可能是一个问题,因为工具提示可能使用 JavaScript 并且必须将其写入页面 - 但 RenderCatalogPart 方法不知道它将输出到哪个页面。有什么办法可以解决这个问题还是我必须想出一个替代方案?

我已将其发布在 Telerik 网站上,但如果有人有任何想法,我也会在这里询问。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

燃情 2025-01-03 13:36:07

Telerik ASP.NET 控件需要 MS AJAX ScriptManager 控件。我想这就是他们也想访问该页面的原因 - 获取对 ScriptManager 的引用。尝试将工具提示的 RegisterWithScriptManager 属性设置为 false,然后查看控件是否呈现。

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.

空心↖ 2025-01-03 13:36:07

这里的问题是必须创建 ToolTips 并将其添加为 PreRender 中的控件,以便可以将其脚本添加到 ScriptManager。

在 PreRender() 方法中创建工具提示集合,然后将它们写入 httpwriter(如上面 RenderCatalogPart 中所示)可以解决该问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文