concept notification message in category sharePoint

appears as: Notification messages, notification messages, Notification Messages, The notification message, notification message
SharePoint 2010 Web Parts in Action

This is an excerpt from Manning's book SharePoint 2010 Web Parts in Action.

Notification messages are the small messages that appear below the Ribbon on the right side when, for instance, a page is loading or saving. The difference between the status bar and notification messages is that the status bar is used for more persistent user information whereas notification messages are used for transient information. Chapter 10 will show you how to utilize these new features in your Web Parts.

Figure 10.2. Notification messages can be used to inform the user about asynchronous events. This figure shows notification messages from the RSS Web Part.

You create a SharePoint notification message by invoking a JavaScript function defined in the SP.js JavaScript file, but you also need the CORE.js JavaScript file. These two files are normally included in the SharePoint master pages. The SP.UI. Notify.addNotification function allows you to add a new notification and SP.UI. Notify.removeNotification removes a notification. The notification message consists of an HTML string, and a Boolean value determines if the message should automatically disappear. Messages added are queued up and shown one after the other.

Every time the timer function is called and before the partial postback occurs, a notification message appears that informs the user that the feed is refreshing. To enhance it even further, you can add HTML with the SharePoint animated loading image like this:

SP.UI.Notify.addNotification( 
'<img src="/_layouts/images/loadingcirclests16.gif"/> Refreshing feed...');

The SP.UI.Notify.addNotification takes two parameters: the first one is the HTML you want to show in the message and the second (optional) parameter is a Boolean value indicating if the message should automatically be removed. The function returns a unique id for the notification message, which can be used to remove it (using the SP.UI.Notify.removeNotification function).

The status bar in SharePoint offers similar functionality as the notification message. The big difference is that notification messages are normally messages shown for a short period whereas the status bar messages are for more long-lived conditions.

Working with the status bar is also similar to working with notification messages. The status bar is defined in the SP.js JavaScript file and you access it using the SP.UI.Status JavaScript namespace. Status messages have a title and message as well as a priority color. The big difference compared to notification messages is that the status bar doesn’t disappear after a few seconds and the status messages aren’t queued. The status bar appears by default under the Ribbon menu and messages can be appended to the status bar or removed.