Share via


Exercise 3: Writing to the Status Bar

This exercise introduces the new status bar in SP 2010 and demonstrates using it from Silverlight

Task 1 – Writing to the Status Bar

In this task, you will add a line of code to the SL codebehind to write to the status bar.

  1. From Solution Explorer, open the file MainPage.xaml.cs and locate the method buttonStatus_Click.
  2. Add the following code:

    C#

    HtmlPage.Window.Eval(JS);

    This code uses the HTMLBridge to run the JavaScript code that is stored in the JavaScript variable declared in the method already. Rather than having you type all of the JavaScript code, simply take a minute and review it.

  3. This finishes the coding for this exercise so go ahead and hit F5 to test out the code. When the browser launches, navigate to https://intranet.contoso.com/sites/EnhancingClient/SitePages/SilverlightApplication1WebPartPage.aspx
  4. After the page loads, click on the Update Status button inside the Silverlight control (the yellow area of the page). You should see the status bar show up under the page header:

    Figure 7

    Status messages

    There are two messages written to the status bar and one of them sets the color of the status bar to red. Both messages include a link to acknowledge the message and remove it from the status bar.

  5. Close the status messages by clicking the Close link next to each, starting with message #2. Notice that the status bar goes back to its normal grey-blue color after closing the high priority message.

Exercise 3 Verification

In order to verify that you have correctly performed all steps of exercise 3, proceed as follows:

Verification 1

In this verification, you can compare the anticipated output shown in step 4 with the actual output shown on your screen. If the two match, you have completed the exercise successfully.