SharePoint 2010 and 2013 have a very useful control for displaying status messages, the SPPageStatusSetter.

The SPPageStatusSetter can be used to provide the end user messages in the same fashion that the SharePoint UI does to provide a more cohesive experience. The status bar comes in four flavors:

  • Blue – For informational type messages

  • Green – For success messages after an action

  • Yellow – For important warning messages (that aren’t error messages)

  • Red – For error messages

Since I use this a lot in my custom solutions, I have created a very simple helper class that I include in my projects so that I don’t need to repeat the same code over and over again:

[csharp]using System.Web.UI.HtmlControls;
using Microsoft.SharePoint.WebControls;

namespace StatusSetterDemo
public class StatusHelper
public static void SetStatus(HtmlForm form, string title, string message, SPPageStatusColor color)
var statusSetter = new SPPageStatusSetter() { Visible = true };
statusSetter.AddStatus(title + ":", message, color);

To call the helper class to set the status, we just provide the Form object to add the element to and the message details:

[csharp]StatusHelper.SetStatus(this.Page.Form, "Error", "Some bad error has occurred.", Microsoft.SharePoint.WebControls.SPPageStatusColor.Red);[/csharp]

Hopefully you find this as useful as I have!

Pin It on Pinterest

Share This
%d bloggers like this: