Saturday, September 20, 2014

SharePoint Master Page Dynamic footer using Delegate controls

Hi there,

I had worked on the requirement to display the custom information like site owner, contact number, email and last date modified in the master page footer information.

So all the data related to the site owner, contact number, email are dynamic and when the new person takes the site owner role, our code should be smart enough to update this information rather than changing the master page file.

Here we used the delegate controls to get the information from the custom list where the items contains the site owner name, contact, email so that the delegate control is able to render this information in the master page footer control.

For adding the delegate controls in the master page, first we have to create the user control and then reference it in the master page with attribute ControlID.


Create the user control with mapping the ControlTemplates folder in the visual studio and then deploy this control with specifying the path using module and elements.xml.

Here is the elements.xml from the module file.

See the attributes Id mapped to the delegate control in the master page.

Now the FooterControl.ascx file has its own custom logic to fetch the information from the  custom list based on the current web context and able to render the same on the master page.

Here is the sample code used for Footer user control page load method. Here the custom list is located in the root web and it is named as SiteOwner with fields Web title, owner name, email, contact.

Final output:





No comments: