每个 Web 部件的 SharePoint Web 部件库详细信息
使用 SPWeb.GetCatalog(SPListTemplateType.WebPartCatalog)
时,它会返回 SPList
,其中当然包含 Web 部件中 Web 部件的 SPListItemCollection
画廊。
循环访问项目时,是否有任何简单的方法来获取 Web 部件的属性?例如AllowClose、CatalogIconImageUrl 等...
我知道我可以使用listItem.OpenBinaryStream 等并加载.webpart 文件的xml 来完成此操作,但我想知道是否有更简单的方法来执行此操作。
When using SPWeb.GetCatalog(SPListTemplateType.WebPartCatalog)
, it returns an SPList
which of course contains a SPListItemCollection
of the web parts in the web part gallery.
When looping through the items, is there any easy way to get properties of the web parts? Such as AllowClose, CatalogIconImageUrl, etc...
I know I can probably accomplish this using the listItem.OpenBinaryStream etc and loading the xml of the .webpart file, but I wondered if there was an easier way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有。如果您像这样加载 Web 部件,您获得的只是
SPListItem
(来自库),而不是SPWebPart
对象(实际上您只能从存在的实例中获得)在页面上 - 或者通过SPWebPartManager
对象加载[即使从图库加载,您也需要以完全相同的方式提取 XML])。您必须执行SPListItem.File.OpenBinaryStream()
并将其激发到XmlReader
或XDocument
对象中,以便于解析。Nope. If you load the webparts like that all you get are
SPListItem
s (which are from the gallery) and notSPWebPart
objects (which you'll realistically only get from instances that exist on a page - or from loading in via anSPWebPartManager
object [and even then loading from the gallery, you would need to extract the XML in exactly the same way anyway]). You'll have to doSPListItem.File.OpenBinaryStream()
and fire it into anXmlReader
orXDocument
object for easier parsing.