// コンテンツエディタWebパーツ生成
Microsoft.SharePoint.WebPartPages.ContentEditorWebPart cewp
= new Microsoft.SharePoint.WebPartPages.ContentEditorWebPart();
// コンテンツに流し込むXMLエレメントを生成
XmlElement contentP = (new XmlDocument()).CreateElement("p");
// コンテンツの設定
contentP.InnerText = "コンテンツエディタの中に書き出したいコンテンツ";
cewp.Content = contentP;
// Webパーツマネージャーを取得
using (SPLimitedWebPartManager ltdWebPartMgr = spWeb.GetLimitedWebPartManager(spFileUrl, PersonalizationScope.Shared))
{
// Webパーツを追加
ltdWebPartMgr.AddWebPart(cewp, strZoneId, intZoneIndex);
// Webパーツの設定を保存
ltdWebPartMgr.SaveChanges(cewp);
}
More than 5 years have passed since last update.
コンテンツエディターWebパーツを追加するサーバーサイドコード(C#)
Posted at
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme