SharePoint 2010 Cookbook: How to Use the Notification Area in SharePoint 2010

Beyond working with status information, you can also customize the Notification Area on the upper right-hand side of the screen below the Ribbon. The Notification Area helpfully tells users such useful information as that a page is loading, or that a save was successful.  Prior to SharePoint 2010, this sort of information was indicated a postback and page refresh. In this article, we will take a look at how to show a message in the Notification Area in SharePoint 2010.

Challenge:

How can I show a message in the Notification Area in SharePoint 2010?

Solution:

A Notification appears in a small text area which gets displayed at the top-right corner of the window, while performing actions such as saving a page, checking out a page, etc., and is similar to the notification Gmail users see when sending an email. The Notification Area is a simple text area with a pale yellow background and a dark yellow border, as shown in the screenshot below. This is a new feature in SharePoint 2010.

 

The Notification Area can display one or more messages. Depending on the setting, a message will either disappear automatically or be disposed the developer manually.

How to use it?

Working with the Notification Area is really easy. The SharePoint team has done great job and wrapped up all of the functionality into the SP.UI.Notify namespace.

The first function is the SP.UI.Notify.addNotification function which takes two arguments: the HTML message to be displayed and a boolean value that determines whether the message is sticky or not:

SP.UI.Notify.addNotification = function(message, bSticky) {
 
}

Sticky notification messages have to be disposed of manually calling the SP.UI.Notify.removeNotification function and passing the ID of the message to dispose.

For example, executing the following call:

var notifyId = SP.UI.Notify.addNotification("Do You Bamboo?", true);

The following sticky notification message will be displayed:

The cool thing about the notification messages is that they can contain HTML and allow you to include images or links to deliver richer feedback to the users.

 

Remove Notification Area

By default, notification messages disappear automatically after five seconds. This value is hard-coded and cannot be modified. However, you also have the ability to display sticky messages, and you may control when these messages disappear.

You can hide notification messages using the SP.UI.Notify.removeNotification message. The only parameter that it takes is the ID of the notification message to hide:

SP.UI.Notify.removeNotification = function(notifyId) {
 
}

Notification messages are a great way to deliver feedback to users, communicating the execution of an operation. The SharePoint 2010 UI API makes it extremely easy to use notification messages in your custom applications developed on the SharePoint platform.

 

Notes:

 

See Also: