简体   繁体   English

如何通过代码将自定义Web部件添加到WebPart页面?

[英]How to add a custom web part to a webpart page through code?

I wanna how to add a custom web part to a webpart page through code? 我想如何通过代码将自定义Web部件添加到WebPart页面? The custom web part is already deployed to the SharePoint site. 自定义Web部件已经部署到SharePoint网站。 It's a MOSS instance. 这是一个MOSS实例。

To place a web part on a page you have to use the SPLimitedWebPartManager which could be retrieved from the actual SPWeb object. 要将Web部件放置在页面上,您必须使用SPLimitedWebPartManager ,可以从实际的SPWeb对象中检索它。

After creating an instance of the web part you want to add to the page, you call the AddWebPart() method of the web part manager and pass the web part instance as a parameter. 创建要添加到页面的Web部件的实例之后,调用Web部件管理器的AddWebPart()方法并将Web部件实例作为参数传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将自定义Webpart(沙盒)添加到页面布局 - How to add custom webpart (sandboxed) to page layouts 如何从WebPart中的页面获取WebPart中自定义设置的引用? - How to get a reference to custom settings in webpart from a page within webpart? 使用“编辑Web部件”界面无需设置Webpart自定义属性 - Set webpart custom properties WITHOUT using the Edit Web Part interface 自定义 Web 部件部署产生“无法导入此 Web 部件”错误 - Custom web part deployment produces 'Cannot import this webpart' error 如何将自定义构建的webpart添加到列表定义项目中的自定义视图aspx页面 - How to add a custom built webpart to a custom view aspx page in list definition project 如何将Web部件页面添加到网站定义? - How to add a web part page to a site definition? 将WebPart添加到“应用程序”页面 - Add a WebPart to an Application page 覆盖SharePoint Server WebPart中的web.config /在Web Part中使用自定义成员资格提供程序 - Overriding web.config in sharepoint webpart/using custom membership provider in web part 通过链接按钮从其他自定义Webpart打开自定义WebPart。 - Open a custom webpart from the other custom webpart through a link button 从 web 部件组件 (spfx-reactjs) 调用 SharePoint 添加新的 webpart function - call SharePoint's add new webpart function from within a web part component (spfx-reactjs)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM