Tuesday, January 15, 2013

How to Add a Custom WebPart within a SharePoint Master Page.

How to Add a Custom WebPart within a SharePoint Master Page.

 

How to Add a Custom WebPart within a SharePoint Master Page.
  • First write your logic and deploy a WebPart to a SharePoint site.
  • Add a New WebPart and add the custom WebPart you have developed.
  • Now open the page within a SharePoint Designer.
  • Now Open a Notepad.
  • Now you have to copy the two things.
  • Copy the Register tag within the Page. This will be in the format as shown below.
  • <%@ Register TagPrefix="WpNs0" Namespace="GroupUsersGrid.GroupUsersGrid" Assembly="GroupUsersGrid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b5c7b45489124c1b"%>
  • Now copy the WebPart Code Generated by SharePoint to your Notepad.
  • This will be in the format as shown below.
  • <WpNs0:GroupUsersGrid runat="server" ID="g_a0e35373_6571_4956_83b1_3cee01e35a1a" Description="My Visual WebPart" Title="GroupUsersGrid" __MarkupType="vsattributemarkup" __WebPartId="{A0E35373-6571-4956-83B1-3CEE01E35A1A}" WebPart="true" __designer:IsClosed="false" partorder="2"></WpNs0:GroupUsersGrid>
  • Now close the WebPart Page.
  • Now Open your Master Page.
  • Now First copy the Register Tag in the Top of the Master Page.
  • Now go to the specified TD where you want to show the WebPart.
  • Now the WebPart Code you have copied before, please select it and copy to the Appropriate TD.
  • Now save the Master Page and run the site.
  • Now you will see the WebPart on Your SharePoint Site Globally.

2 comments:

  1. Thanks for your help.
    It is working fine with my SharePoint 2010 website.

    I also had this kind of situation with SharePoint 2013 website as well.
    In SharePoint 2013, the wonderful snippet feature is available.
    After creating and deploy the custom web part , we can use the html for that and copy paste that html in our master page html file , which will be automatically sync with the .master file.

    And our task done.

    I am specifying this for SharePoint 2013.
    Thanks

    ReplyDelete
  2. okk thats fine for farm solution but waht about sand box solution??
    and i tried the same steps but tht didn't worked for me but when i have created fully qualified assembly after that only the steps you mentioned worked for me

    ReplyDelete