• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1345
  • Last Modified:

Pagelayout add a default content editor wb

Whats the code snippet for adding a default content editor webpart to a custom pagelayout?

1 Solution
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:

Are you looking for a coding solution? It is not clear from your question. If not, read on.

Best way to go about this is to open the page layout in SharePoint designer. At the place where you want the CEWP, add a div tag. Change to design view and select the new div. Then click Insert > Web Part > Content Editor Web part. Go back to code view and study the code. It will look something like

	<div><WebPartPages:ContentEditorWebPart webpart="true" runat="server" __WebPartId="{0C023812-0992-4428-B562-1F510E9F42D9}"><WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
	<Title>Content Editor</Title>
	<Description>Allows authors to enter rich text content.</Description>

Open in new window

Mind that each web part will have its own unique ID, so you cannot just copy and paste the above.

Hope that helps,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now