Thursday, April 18, 2013

Sharepoint Delegate control - Notification bar in sharepoint

In this post I am going to show how to add a notification bar in the sharepoint site(Notification bar is used to display notification to the users about the site maintenance activity)
Step 1: Override the delegate control in the master page
Step 2: Associate this delegate control as sharepoint feature(This will be usefull for the site admin, whenever its required they will be activate and deactivate this feature)
Open Visual Studio and create new project called NotificationFeature
Add new sharepoint Feature Called NotificationFeature and set the scope to Site level.
Add new user control called NotificationControl(Map to sharepoint control template folder at the 14 hive)
Open NotificationControl.ascx file and add the below code to display notification bar.
Here I have added jQuery reference and javascript function which set the div background color and div tag to display the message. (Adding jQuery reference and validate method is optional we can set the background color for the div tag directly)
Add New Empty element to the project and name it as NotificationControl.
Open Element.xml file and add below code.
<Control Id="AdditionalPageHead" ControlSrc="~/_CONTROLTEMPLATES/NotificationFeature/NotificationControl.ascx" Sequence="15100" /> Finally our Element.xml file looks like below.

Add jQuery file to the layouts folder. This step is optional since I am applying style for the div element through jQuery I am using this else we can skip this step.
Final structure of our project:
Build, Package and deploy the solution. And activate the Notification Feature at the site level.
Now our notification bar will be displayed when the user open the site.

No comments:

Post a Comment