Sharepoint 2010:如何持久保存 SPList 对象?
我正在编写具有附加功能的共享点资产选择器对话框的替代品。
需要浏览位于其他网站集中的媒体库。 因此,我添加了一个配置页面,您可以在其中将媒体库的 URL 添加到共享点属性包中。
在自定义 AssetPicker 对话框中,我将从配置的 URL 创建的 SPList 对象添加到名为 medialibs 的成员列表中。
我知道处理SPList对象所属的SPWeb和SPSite非常重要。我在页面的 OnUnload 事件中执行此操作,但发现每次回发时都会调用 OnUnload。 我无法每次在 OnLoad 中重建 medialibs 列表,因为页面上有一个树视图控件,它保存对 medialibs 中 SPList 对象的引用。如果我处理并重建它们,这些对象就会是新的且不同的。 树视图不能每次都重建,因为它会丢失打开哪些节点的信息。
如何通过回发保留媒体库的内容?如何确保当用户离开页面时正确处理 medialib 中的 SPList 对象?
谢谢!
I am writing a replacement for the sharepoint asset picker dialog with additional features.
There is a requirement to browse media libs which are located in other site collections.
So I added a configuration page where you can add the URLs to the media libs to the sharepoint property bag.
In the custom AssetPicker dialog I added the SPList objects created from the configured URLs to a member List called medialibs.
I know that it is very important to dspose the SPWeb and SPSite the SPList object belongs to. I do that in the OnUnload event of the page, but discovered that OnUnload is calld every time on postback.
I can't rebuild the medialibs list every time in OnLoad because there is a treeview control on the page which holds references to the SPList objects in medialibs. If I dispose and rebuild them, the objects are new and different.
The treeview cannot be rebuilt every time, because it would lose the information which nodes are opened.
How do I persist the contents of the medialibs over postback? How do I ensure the SPList objects in medialibs are properly disposed when the user leaves the page?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么你需要持久保存媒体库。在初始加载时,您将根据 SPList 对象填充 TreeView。然后 ViewState 处理跨请求的 TreeView 的持久性。 SPSite/SPWeb 对象将在填充阶段被处置(
using
语句效果很好)。我错过了什么吗?I'm not sure why you would require medialibs to be persisted. On the initial load, you would populate the TreeView based on your SPList objects. ViewState then handles persistence of the TreeView across requests. SPSite/SPWeb objects would be disposed of at the population stage (
using
statements work well). Did I miss something?