In this post, we will discuss how we can create and deploy a web part page using visual studio 2013 in SharePoint 2013. In web part pages, users can directly add contents to the page by adding web parts to the page from the browser itself. So here we need to add web part zones to the page. Web part zones is like a container which allows users to add controls into it.
In this post, we will create a visual studio solution which will create the web part page & deploy it to the Site Pages library.
Open Visual Studio 2013 then click on File -> New -> Project. This will open the New Project dialog box, From the left side from the installed templates go to Templates -> Visual C# -> Office/SharePoint -> SharePoint Solutions. Then choose SharePoint 2013 – Empty Project. Make sure to choose .NET Framework 4.5 version. Give a name and location as shown in the fig below:
Then give a local site for debugging. And then choose the option as farm solution. You can choose here Sandboxed solutions also. But in this example I have choose farm solution.
Then Right click on the Project then Add -> Add new project. In the Add New Item dialog box, from the installed templates select Visual C# Item, Office/SharePoint and then choose Module. Give a name for the Module as shown in the fig below:
By default it will add one Elements.xml file and Sample.txt file. By default the solution explorer will look like below:
After this rename Sample.txt file to <your name of the page>.aspx . Also rename the feature to a meaningful name and the solution explorer will looks like below:
Then add the below code to the .aspx page.
<%@ Page Language=”C#” MasterPageFile=”~masterurl/default.master” Inherits=”Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register TagPrefix=”WebPartPages”
Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<asp:Content ContentPlaceHolderID=”PlaceHolderMain” runat=”server”>
<h1>Our Custom web part page designed from visual studio 2013</h1>
<WebPartPages:WebPartZone ID=”top” Title=”Top” runat=”server”>
<WebPartPages:WebPartZone ID=”buttom” Title=”Bottom ” runat=”server”>
Now we will change the Elements.xml like below. Here Type=”GhostableInLibrary” which tells SharePoint that we would like to make the file that is added to the library an uncustomized file. Here carefully give the Module URL and File Path & URL carefully.
<?xml version=”1.0″ encoding=”utf-8″?>
<Module Name=”SitePages” Url=”SitePages”>
<File Path=”SitePages\MyCustomWebPartPage.aspx” Url=”MyCustomWebPartPage.aspx” Type=”GhostableInLibrary” />
Now it is time to deploy the solution. Right click on the Solution click on Deploy Solution which will deploy the solution to the local SharePoint site which you have provided at the begining.
But if you want to deploy to any other server other than development servers like stage or production server then you can follow this URL to know how we can deploy the solution using PowerShell.
Once you deploy the solution successfully, go to the gear icon then Site Settings. Under Site, Actions click on Manage site features. This will open the Site Features page, you can see the “MyCustomWebPartPage Feature1” will be inactivate state as shown in the fig below:
Now if you will go to the Site Pages directory. You can see the page which we have deployed in the gallery. You can see the fig below:
Click on the page, you can see the page which has created like below:
web part page in SharePoint 2013 using visual studio have added two web part zone to the page which you can see after editing the page.
the web part page SharePoint 2013 visual studio 2013.
Hope this will be helpful to you.
-: FREE PDF e-Book Download :-
51 JSOM Examples in SharePoint Online
You May Also like the Following SharePoint Online Tutorials: