All About SharePoint 2010/2013

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 0 Trackbacks


Exploring SharePoint 2013 Online

Developing Nintex Workflows

Exploring SharePoint 2013

Acquired MCPD : SharePoint 2010 Developer

Share on Facebook

Article Categories


Post Categories

In SharePoint 2010, Status bar is used to display information/warnings without disturbing user with Javascript alerts. Please don't think it is Browser's Status bar. It's a special information bar which displays below ribbon/top bar when invoked. No Server side code or manual setup required to enable status bar. The required functions are bundled in SP.UI.Status class that defined in SP.Js/SP.Debug.Js and it's included in SharePoint master page. So no need to include Js manualy to use Status bar.

Well, Javascripts alerts are not helpful to display HTML content, images, links. Where Status bar accepts HTML content and can be invoked just with Javascript.

SP.UI.Status Functions
The SP.UI.Status class has 6 functions. They are

  1. SP.UI.Status.addStatus(strMessageHeading, strHTMLContent, boolAtBegining) This function used to display specified content in Status bar. The parameters are self explanatory. boolAtBegining parameter specifies whether this content should be shown at First(just like to give priority) and it's useful when more than one status messages invoked.
  2. SP.UI.Status.appendStatus(strStatusID, strHTMLContent) This function appends HTML content with an existing status bar content.
  3. SP.UI.Status.updateStatus(strStatusID, strHTMLContent) This function updates/replaces existing HTML content with given HTML content.
  4. SP.UI.Status.setStatusPriColor(strStatusID, strColor) This function sets/changes the color of status bar. Only four colors[red, yellow, green, blue] are allowed which specifies the priority. Red - High Priority, yellow, green, blue - Low Priority. When two colors applied on same status bar then High priority color will be considered by SharePoint.
  5. SP.UI.Status.removeStatus(strStatusID) This function removes the specific Status bar.
  6. SP.UI.Status.removeAllStatus(boolHideStatus) This function removes all Messages. If the boolHideStatus passed as true then it'll hide all status bar with messages. Otherwise it'll hide only Status Message but a thin status bar will remains in place.

How to add code?
Follow the steps to add Content Editor Webpart and add HTML/Javascript Code.

  1. Site Actions -> Edit Page (or Edit page Icon on top bar)
  2. Click Editing Tools(Tab) -> Insert (Tab) -> Webpart
  3. Select Media and Content (Section) -> Content Editor.
  4. Select Content Editor Webpart (Black triangle on top right of the webpart)-> Edit Webpart.
  5. Editing Tools (Tab) -> Format Text -> HTML -> Edit HTML Source.

Edit HTML Content of Content Editor WebPart

Demo Code
 <Script type="text/javascript">
function showInfo()
  strStatusID = SP.UI.Status.addStatus(
"Information : ", "<img src='/_Layouts/Images/STS_ListItem_43216.gif' align='absmiddle'> <font color='#AA0000'>Registration process <i>completed</i>.</font>", true);

" Next : ", " <b>You can <a href='Login.aspx'>Login Now</a>", false);

function updateInfo()
"Status Update: This content updated with " + strStatusID + " using updateStatus");

function updateInfoRed()

function removeInfo()

function removeAllInfos()

div class="ms-toolpanefooter">
input type="button" onclick="Javascript:showInfo();" value="Show Info" class="UserButton" />
input type="button" onclick="Javascript:appendInfo()" value="Append Info" class="UserButton" />
  <input type="button" onclick="Javascript:updateInfo()"value="Update Info" class="UserButton" />
input type="button" onClick="Javascript:updateInfoRed()" value="Make Red" class="UserButton" />
  <input type="button" onClick="Javascript:removeInfo()" value="Remove Info" class="UserButton"/>
<input type="button" onClick="Javascript:removeAllInfos()" value="Remove All Infos" class="UserButton"/>

Add Status

Append Status

Update Status

Change Color of Status Bar

Remove Status

posted on Thursday, November 18, 2010 10:59 AM


# re: How to use Status Bar in SharePoint 2010? 5/4/2011 3:54 PM jss
Hi. Great post!.
I have a question for you. Have you tried to append several lines of information to the same status bar. I have, and something weird happens. Despite having "setStatusPriColor(strStatusID, "red")" the color of the bar doesn't persist (the first three or four lines are red, then the next line turns yellow, then a kind of gradient). So when the status bar has more than 3 lines I get a multicolor bar. The result is the same no matter if I am appending or just adding new status bars.

Any idea? Thank you so much.

# re: How to use Status Bar in SharePoint 2010? 5/4/2011 4:05 PM Venkatesh R
Hi Jss,
The Status bar is just to show simple messages. You can't show paragraphs or essay in it. :)
The Status bar uses CSS Sprite for Background. (Ie. One image with multiple gradients can be used via CSS to display different colors based on top pixels). So if the heigh exceeds specified limit then it'll show the remaining gradients as well. This can't be avoided.
Solution: Request to short the message which you want to display. If you need to display block of info then write custom display message box and provided link in status bar like "Read More".

# re: How to use Status Bar in SharePoint 2010? 5/4/2011 4:13 PM jss
Hi Venkatesh. I'll try your solution :)

# re: How to use Status Bar in SharePoint 2010? 5/12/2011 12:53 PM Panco
How to access the status directly from the server side code? eg. display a persistent status after a database update.

# re: How to use Status Bar in SharePoint 2010? 5/12/2011 3:21 PM Venkatesh R
Hi Panco,
Status bar is used at client side(browser) to display message. If you want to fetch data from status bar then use a hidden variable and assign same value which u pass to status bar via Java Script.
If you want to pass data from Server side to client side then

Add the below function in Javascript.
function showInfo(strMessage)
strStatusID = SP.UI.Status.addStatus(strMessage, true);
SP.UI.Status.setStatusPriColor(strStatusID, "yellow");
Add a label "lblScripter"
Then in Server Side Code add
lblScripter.Text = "<Script language='javascript;>showInfo('" + strYourMessage + "');</script>";
This will invoke the Javascript and show the statusbar.

# re: How to use Status Bar in SharePoint 2010? 7/3/2011 4:30 PM Anmol
Good post. Similar post can be found here

# re: How to use Status Bar in SharePoint 2010? 9/27/2012 9:49 PM Tabares
Thank you Brohter! very useful....

Best Regarts

# re: How to use Status Bar in SharePoint 2010? 5/21/2013 5:31 PM santosh
Will this work for anonymous users?? I tested it for Read only users and it is not working. Below is the url where i have put my code. Can you please help me.

I am using it on server side by scheduling the message

# re: How to use Status Bar in SharePoint 2010? 2/10/2014 7:07 PM Björn
@jss: It's a Little late, but you can deactivate the background-Image for that special case:
jQuery("#pageStatusBar").css({ "background-image": "none" });
works fine for me :-)

# re: How to use Status Bar in SharePoint 2010? 2/24/2014 7:55 PM PegH.
Notifications display but not Status messages.

I checked the s4-statuscontainer <div> in my master page. It is there and not disabled and F12 IE developer tools doesn't show any errors.

Any ideas of other things I could check to be able to display the status messages?


comments powered by Disqus