Sharepoint 2013 - Web Parts

Web parts are the server-side components that takes in data from different resources such as lists, RSS feeds or news sites, and output meaningful data onto the web page.

A designer can designate areas within a page to be web part zones, into which many web parts can be inserted. For example, let's say we want a list of the latest news to be displayed on the front page of our news website. We would create a web part which takes in the list of news items, sort them according to the most recent items, and then output the first 10 results. On the home page, we would insert a web parts zone and insert the web part we just created into it. Now each time the page is displayed, it will display the latest news.

And you have probably seen web parts in action already without realizing it. Whenever a list is created, and you view it on Sharepoint, the interface on Sharepoint where you view your list is actually a web part itself.

The interface on Sharepoint where you view your list is actually a web part

This web part takes the 'Product' list (data) and display each item's 'ID', 'Name', 'Description', 'ReleaseDate', 'DiscontinuedDate', 'Rating' and 'Price' columns in a table format. This is a type of Lists and Libraries web part; there are other types of web parts such as Content Rollup, Documents, Forms, Media and Content, and People web parts. There is an Overview of Web Parts available in SharePoint Foundation 2010, which also applies to Sharepoint 2013.

However, these out-of-the-box, default web parts are of little use on a public-facing website, since its looks are bland and standard. Most of the times you would want to customize the looks of your web parts, and usually this means they are not in a table format and looking black-and-white. To build our own custom web parts, you must learn a bit of ASP.NET.

Types of web parts

There are two types of web parts you can use in Sharepoint - the one provided by the ASP.NET framework, and those based on Sharepoint. In the official documentations, the ASP.NET Web parts are recommended, because these web parts can be used in other ASP.NET applications, apart from just inside Sharepoint websites.

ASP.NET Web parts

These web parts are built on top of the ASP.NET Web Part infrastructure. The WebPart class is inherited from the System.Web.UI.WebControls.WebParts namespace, which is defined in the System.Web.dll library.

Sharepoint-based web parts

These web parts are built inside Sharepoints and inherits from the WebPart class in the Microsoft.SharePoint.WebPartPages namespace, which is defined in the Microsoft.SharePoint.dll library.

comments powered by Disqus