0

I have some code that creates a new status bar but it just stays on top without fading. It doesn't even have an 'x' to close it manually. The following is how I am adding a new SP status from code behind. How can I make this fade out after a couple seconds? jQuery? Am I missing an argument that allows the status to be closed?

var scriptTemplate = @"
      ExecuteOrDelayUntilScriptLoaded(function(){{
         ExecuteOrDelayUntilScriptLoaded(function(){{
             var statusId = SP.UI.Status.addStatus('{0}');
               SP.UI.Status.setStatusPriColor(statusId, '{1}');
               setTimeout(function(){SP.UI.Status.removeStatus(statusId);}, 2000);
               }},
           'core.js'
            )}},
        'sp.js'
        );";

var script = string.Format(scriptTemplate, message.Replace("\"", "\\\""), color);

Page.ClientScript.RegisterClientScriptBlock(typeof(MyTrainingUserControl),  "notifysuccess", script, true);
Michael Colbs
  • 3,919
  • 2
  • 48
  • 96

1 Answers1

2

This can be achieved by simply using the setTimeout function.

    var statusID = SP.UI.Status.addStatus('bold text', 'message');

    setTimeout(function(){
     SP.UI.Status.removeStatus(statusID);
    }, 2000);