开发者

SharePoint 2010: Problems with a connection provider web part which uses an UpdatePanel

开发者 https://www.devze.com 2023-01-25 19:05 出处:网络
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 U

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 p开发者_开发问答age 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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号