SharePoint 2010:使用 UpdatePanel 的连接提供程序 Web 部件出现问题

发布于 2024-10-02 18:10:51 字数 359 浏览 0 评论 0原文

我可能会以完全错误的方式处理这个问题,但这就是我正在做的事情:

我有 2 个自定义 Web 部件:公司日历和约会列表。两者都是可视化 Web 部件,并且都包含 UpdatePanel 控件。日历提供日期,约会列表消耗日期。当日历部分中选定的日期发生更改时,约会列表会收到通知。 UpdatePanel 的目的是防止整个页面被刷新。

当页面加载时,这工作正常。但是,当日历日期更改时,会引发回发。预约部分已刷新,但提供商链接为空。 (即连接未显式重新初始化)因此无法从提供程序(日历)获取日期。

我尝试将提供程序保存在 ViewState 中,但收到一条错误消息,指出日历部分未标记为可序列化。此时我开始怀疑我是否做错了:-/

应该如何完成?

I might be going about this in totally the wrong way but this is what I'm doing:

I have 2 custom web parts: a company calendar and an appointment list. Both are visual webparts and both contain an UpdatePanel control. The calendar provides a date and the appointment list consumes a date. When the selected date in the calendar part changes the appointment list is notified. The UpdatePanel is intended to prevent the whole page from being refreshed.

This works fine when the page is loaded. However, when the calendar date is changed, a postback is raised. The appointment part is refreshed but the provider link is null. (i.e. the connection is not explicitly reinitialised) Therefore it is not possible to fetch the date from the provider (Calendar).

I tried to save the provider in the ViewState but I get an error saying that the calendar part is not marked as serialisable. At this point I start to wonder if I'm doing this wrong :-/

How should this be done?

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

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

发布评论

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

评论(1

樱花细雨 2024-10-09 18:10:51

这就是我让它发挥作用的方式。

  • 在我的提供程序中创建一个小的可序列化类,该类实现接口,
  • 消费者在 PageLoad 上的 ViewState 中保存对该类的引用
  • ,消费者可以使用 ViewState 中存储的类的实例与提供程序进行通信
  • 警告消费者应该设置值后首先从提供者读取值! PreRender 可能是执行此操作的最佳时机,但这取决于实现

This is how I got it to work.

  • Create a small serializable class in my provider which implements the interface
  • the consumer saves its' reference to the class in its' ViewState on PageLoad
  • the consumer is able to communicate with the provider using the instance of the class staored in the ViewState
  • WARNING the consumer should first read the value from the provider after the value has been set! PreRender is probably the best time to do this but it will depend on the implementation
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文