Sometimes we have a requirement like we need to show some sort of warning messages or some notification to the client as a feedback of the action performed by him when certain criteria’s are met.
Sharepoint 2010 provides us a very simple way of showing the notifications by which we can show the response immediately to client without any server side postback.
SP.UI.Notify is the class which contains the addNotification function by which we can add the notification on Sharepoint UI.
To use this class add the reference of SP.js file in your file. In Sharepoint 2010 it is already included in master page.
You can find the SP.js in the below mentioned location:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
To add the notification add the below mentioned Javascript in the click event of the button.
SP.UI.Notify.addNotification(‘My Notification’);
Below is the example:
btnShowNotification.Attributes.Add("onClick", "SP.UI.Notify.addNotification('My Notification:Have a Good Day!');");
Now when a user click on the ShowNotification button he will see the notification.
No comments:
Post a Comment