Thursday, August 25, 2011

Content Editor Web Part in SharePoint 2010

In this post, we will discuss what is content editor webpart in SharePoint 2010. Also, you can check out my previous posts on:

- Configure search service application sharepoint 2013/2016 step by step

- How to use LINQ in SharePoint 2013/2016

Create an event handler to prevent items from deleting item from SharePoint list using Visual Studio 2010

Content Editor webpart is an out of box webpart comes with all SharePoint 2010 versions. It can hold HTML, JavaScript, and CSS. You can edit the content editor webpart, and point it to a
txt file location where the actual content is.
To add a content editor web part into your page. Edit the Page -> From the ribbon click in Inset then select the web part. Then from the list of web part categories, select the Media and Content category and then Select the Content editor web part and click on add as shown below figure.
-->

To get the source editor in the ribbon is a bit difficult, for this select the content editor web part then from the ribbon, From Editing tools select Format text and then click on the HTML in the right-hand side. then click on Edit HTML source as shown in the figure below.

To start writing text to the web part edit the web part and then write the text. Then click on apply and Ok.

To add Javascript code go to the HTML source as explained above and write the code in the editor like below
<script type="text/javascript">document.write("Hello World !!!");</script>

You can also check about XSLT list view web part in SharePoint 2010