Share via


Code to Manage Common Error Messages to Users

The MessageManager object is created in the Global.asa file. For the purposes of this example (although this practice is not recommended), it will be created on an ASP page. In this example, a MessageManager object is created, and two languages (Informal and Formal) are added to it. Following this, a message ("greeting") is added to each language. The message is then written to the page in each language.

  1. Instantiate the MessageManager object.

    Dim oMessMgr, sMessage
    Set oMessMgr= Server.CreateObject("Commerce.MessageManager")
    
  2. Add two new languages to the MessageManager object, specifying the US Locale (1033).

    Call oMessMgr.AddLanguage ("Informal", 1033)
    Call oMessMgr.AddLanguage("Formal", 1033)
    
  3. Add two new messages to the MessageManager object.

    oMessMgr.AddMessage "greeting", "Hi, World!", "Informal"
    oMessMgr.AddMessage "greeting", "How do you do, World.", "Formal"
    
  4. Get the informal message, and write it to the page.

    sMessage = oMessMgr.GetMessage("greeting", "Informal")
    Response.Write "Informal Message: "& sMessage & "<BR>"
    
  5. Get the formal message, and write it to the page.

    sMessage = oMessMgr.GetMessage("greeting", "Formal")
    Response.Write "Formal Message: " & sMessage & "<BR>"
    


All rights reserved.