Displaying Status Information

The Connection object includes a Status property that contains the current status information of the AB Suite system. To display the status information, you can add a label on the Layout page. Adding the label on the Layout page (_Layout.cshtml) allows it to be included in all the Views.

To add a status field to the Layout page, perform the following:

  1. Open the _Layout.cshtml file from the Views or Shared folder.

  2. Add a label to display the status after the @RenderBody() statement as shown in the following code snippet:

    <div class="container body-content">
        @RenderBody()
    		<label class="bottom-left alert">@ViewBag.Status</label>
    		<hr />
    		<footer>
    	       <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
    		</footer>		
  3. Initialize the ViewBag.Message variable with the text in the MyContact() action method of HomeController:

    public ActionResult MyContact(ContactModel mdl)
    {
    		ViewBag.Message = "My Contacts Page.";
           // Retrieve objects from Session State to get the 
           // current status line
    
          // Add it to the ViewBag so that the View can use it
           IConnection ABSConnection = (IConnection)Session["ABSConnection"];
    ViewBag.Status = ABSConnection.Status;
                
           return View(mdl);
       }	

Note: A ViewBag is a temporary storage area used to pass information to a View for displaying it on the form. The label displays the text contained in the Status variable stored in the ViewBag.

When the View is displayed in the browser, the status text appears below the rendered form.