1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コンテンツエディターWebパーツを追加するサーバーサイドコード(C#)

Posted at
// コンテンツエディタ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);
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?