The out-of-the-box master pages included with SharePoint 2013 provide a delegate control to place branding text in the top-left corner of the page. For standard SharePoint instances, the text SharePoint is displayed. For SharePoint on Office 365, Office 365 is displayed instead.
In this recipe, we will simply replace the control with a custom control that displays our own text. The text could also be replaced by editing the master page or by modifying the SuiteBarBrandingElementHtml
property on the SharePoint web application. Using the custom control provides us the ability to add additional functionality if desired. For instance, the control could be used to add additional links, a menu, or other interactive content.
We should have already created our Visual Studio project in the Creating a Visual Studio solution for custom delegate controls recipe of this chapter before starting this recipe.
Follow these steps to replace the suite bar branding text using a delegate control:
CONTROLTEMPLATES
mapped folder.CustomSuiteBarBranding.ascx
for example and then click on Add.ASCX
file if it is not already open.<div class="ms-core-brandingText">Custom SharePoint Branding Text</div>
CustomSuiteBarBranding
for example.Elements.xml
file from the new element, register our custom control with the SuiteBarBrandingDelegate
control as follows:<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Control Id="SuiteBarBrandingDelegate" Sequence="10" ControlSrc="~/_controltemplates/15/Code6587EN.Ch07/CustomSuiteBarBranding.ascx"> </Control> </Elements>
CustomSuiteBarBranding
(the name of the user control we created without the .ascx
extension)$SharePoint.Project.AssemblyFullName$
Code6587EN.Ch07.CONTROLTEMPLATES.Code6587EN.Ch07
(the full namespace for the user control, without the name of the class itself)True
True
CustomSuiteBarBranding
(the name of the class for the user control)The out-of-the-box control used by the SuiteBarBrandingDelegate
delegate control displays the HTML snippet stored in the SuiteBarBrandingElementHtml
property of the current SharePoint web application. In this recipe, we replaced the default control with our own delegate control that adds our text to the page.
We are using the same CSS class that the out-of-the-box text uses to allow the content to display with the standard style. Relying on the SharePoint classes allows the content to inherit the styles provided by the current SharePoint theme.
18.118.137.7