• 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?

0
MickMorg
Asked:
MickMorg
1 Solution
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

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>
	<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
		<ID>g_0c023812_0992_4428_b562_1f510e9f42d9</ID>
</WebPart></WebPartPages:ContentEditorWebPart></div>

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,

teylyn
0
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