Vwa.Page.getId Method

Last modified: June 27, 2011

Applies to: SharePoint Server 2010

Returns the unique identifier of the active page within the document.

var value = Page.getID()

string A string that represents the unique identifier of the active page within the document.

The unique identifier is the Microsoft Visio 2010 PageSheet name that is established when the .vdw file is published. This name is the same as that returned by the Visio 2010 Page.Name property.

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.

The following example displays a custom HTML message in the Visio Web Access Web Part that lists each page in the Web Drawing.

<script type='text/javascript'>

// Add a button to display or dismiss the custom message.
document.write("<input type='button' value='Show Message' onclick='buildPageList()' />");

// Declare global variables.
var vwaControl;
var vwaPages;
var isPageSet;
// Hook into the AJAX Sys.Application.load event.

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

// 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;
    return webPartElementID;

// Check to see whether the currently rendered page has already been selected by user.
function onDiagramComplete() {
    if (!isPageSet) {

// Create list of pages in the currently displayed Web Drawing.
function buildPageList() {
        // Get references to the pages in the Web Drawing.
        vwaPages = vwaControl.getAllPageIds();
        var pageCount = vwaPages.length;
        var vwaPage = vwaControl.getActivePage();
        var vwaPageName = vwaPage.getId();
        var vwaPageId;

        // Create an HTML fragment.
        var htmlBuilder = "<h1>Pages In This Diagram</h1>";
        htmlBuilder += "Select a page from the list to dismiss this message.<br />"
        htmlBuilder += "<ol id='pages'></ol>";
        // Display the HTML fragment in Visio Web Access Web Part.

        // Add DOM nodes (HTML content) in the displayed HTML fragment for each page in the Web Drawing.
        for (var i = 0; i < pageCount; i++){
            // Get page ID from array of pages IDs.
            vwaPageId = vwaPages[i];

            // Create a new list item element and text for the list item.
            var newNode = document.createElement("li");
            var newText = document.createTextNode(vwaPageId);
            // Append new nodes to the displayed HTML fragment. 

            // Add a new text node if the page is currently displayed in Web Drawing.
            if (vwaPageName == vwaPageId){
                var activeText = document.createTextNode(" (Current)");

            // Set the id attribute for list item to the ID of the VwaPage object and set callback for the onclick event.
            newNode.setAttribute("id", vwaPageId);
            newNode.setAttribute("onclick", "javascript:setPage(this)");


// Go to the page in the list clicked by the user and dismiss the displayed message.
function setPage(callingNode) {
    try {
        // Dismiss the custom HTML message.
        isPageSet = true;

        // Get id from calling DOM node and set the corresponding page.
    catch(err) {