Condividi tramite


Vwa.VwaControl.displayCustomMessage Method

Applies to: SharePoint Server 2010

Displays a custom HTML error message in the Visio Web Access control and disables interaction with the currently rendered Web Drawing page.

var value = VwaControl.displayCustomMessage(string HTML)

Parameters

HTML An HTML string that specifies the error message to display.

Return Value

Void Returns nothing.

Remarks

For more information about how to add a Visio Web Access Web Part to a SharePoint Web Parts page, see Customizing Visio Web Drawings in the Visio Web Access Web Part.

Example

The following example displays the Web Part ID of the Visio Web Access Web Part and the URL of the Web Drawing displayed in the Web Part.

<script type="text/javascript">

// Hook into the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Define global variables.
var vwaControl; 
var webPartElementID;

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
            webPartElementID = getVWAWebPartID();
            vwaControl= new Vwa.VwaControl(webPartElementID);
            vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    }
    catch(err){
        alert(err);
    }
}

// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID() {
    
    // Get a NodesList of all the div tags on the page. 
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;
    
    // Iterate through the NodesList to get the node with the class attribute "VisioWebAccess."
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];
        
        // Return the first instance of the Visio Web Access Web Part.
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

// Capture references to global variables.
function onDiagramComplete() {
    try{
        // Get the URL for the drawing currently displayed in the Visio Web Access Web Part.
        var drawingURL = vwaControl.getDiagramUrl();
        
        // Display a custom message with the Visio Web Access Web Part ID and drawing URL.
        vwaControl.displayCustomMessage(
            "<b>Visio Web Access Web Part ID is:</b> " + webPartElementID + "<br>" +
            "<b>Diagram was loaded from:</b> " + drawingURL + "<br><br>" +
            "<a href='javascript:hideMessage()'>" + 
            "Click here to dismiss this message<\/a>");
    }
    catch(err){
        alert(err);
    }
}

// Hide the message when the user is done with it.
function hideMessage(){
    try{
        vwaControl.hideCustomMessage();
    }
    catch(err){
        alert(err);
    }
}

</script>

See Also

Reference

Vwa.VwaControl Class

Vwa.VwaControl Class Methods