.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
hdjk11
Shivakumaran
dfefde5
hoangnganvy1993

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Implement Custom SuiteLinks Delegate Control In SharePoint 2013

Posted By:Sagar Pardeshi       Posted Date: January 16, 2016    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we will see how to implement SuiteLinks Delegate Control in SharePoint 2013
 

SuiteLinksDelegate

It is a new delegate control introduced in SharePoint 2013. If you are looking to add a new link just next to "Sites, NewsFeed, SkyDrive" etc, on the top bar of your SharePoint site you can now do that with a new delegate control "SuiteLinksDelegate". The SuiteLinksDelegate control will allow us to modify the default links,

For Example: To add our own links, in the "suit links".

Header before

Header

Step 1: Create One Empty SharePoint Project and provide the Solution Name and choose the Solution Path and click OK.

Step 2: Deploy the Solution as Farm Solution. Provide the Url in next screen and validate the connection.

Step 3: Add New UserControl to the Project from the Templates and provide a Name to it, in our case it is "MyCustomSuiteLinksDelegate"

UserControl

Now our Solution Explorer looks as follows,

MyCustomSuiteLinksDelegate

Step 4: Add reference to Microsoft.SharePoint.Portal dll.

Solution Explorer
 
Ensure your control inherits from MySuiteLinksUserControl like this:
 
public partial class MyCustomSuiteLinksDelegate: MySuiteLinksUserControl

Step 5: Code snippet for the ascx.cs file.
  1. using System;  
  2. using System.Web.UI;  
  3. using System.Web.UI.WebControls;  
  4. using System.Web.UI.WebControls.WebParts;  
  5. using Microsoft.SharePoint;  
  6. using Microsoft.SharePoint.Utilities;  
  7. using Microsoft.SharePoint.WebControls;  
  8. using System.Globalization;  
  9. using System.IO;  
  10. using System.Collections;  
  11. using Microsoft.SharePoint.Portal;  
  12. using Microsoft.SharePoint.Portal.WebControls;  
  13. namespace SuiteBarBrandingDelegate_Example.ControlTemplates.SuiteLinksDelegate_Example  
  14. {  
  15.     public partial class MyCustomSuiteLinksDelegate: MySuiteLinksUserControl
  16.     {  
  17.         protected void Page_Load(object sender, EventArgs e)  
  18.         {}  
  19.         protected override void Render(HtmlTextWriter writer)  
  20.         {  
  21.             writer.RenderBeginTag(HtmlTextWriterTag.Style);  
  22.             writer.Write(".ms-core-suiteLinkList {display: inline-block;}");  
  23.             writer.RenderEndTag();  
  24.             writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-core-suiteLinkList");  
  25.             writer.RenderBeginTag(HtmlTextWriterTag.Ul);  
  26.             RenderSuiteLink(writer, "http://AboutUs/""About Us""lnkSearchLink"false);  
  27.             RenderSuiteLink(writer, "http://ContactUs/""Contact Us""lnkSearchLink"false);  
  28.             RenderSuiteLink(writer, "http://Feedback""Requisition Manager""lnkSearchLink"false);  
  29.             writer.RenderEndTag();  
  30.             base.Render(writer);  
  31.         }  
  32.     }  
  33. }  
Step 6: Add Elements.xml file to the Solution, provide the name and click Add.

Elements

Step 7: Click on elements.xml file and paste the following code snippet inside the elements tag.
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.     <Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  3.         <!-- Adding DelegateControl reference to our custom SuiteSuiteLinksDelegate Control -->  
  4.         <Control ControlSrc="/_controltemplates/15/SuiteLinksDelegate_Example\MyCustomSuiteSuiteLinksDelegate.ascx" Id="SuiteLinksDelegate" Sequence="90" /> </Elements>  
Step 8: Final step is to build and deploy, then the SharePoint text will override with the Text of the portal.

The final outcome will look as in the following,

Menuv

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend