ToString Method

SiteMapNode.ToString Method ()


Converts the value of this instance of the SiteMapNode class to its equivalent string representation.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public override string ToString()

Return Value

Type: System.String

The string representation of the value of this SiteMapNode.

The ToString method returns the Title property of a SiteMapNode object.

The following code example demonstrates how to compare the ToString method to the Url and Title properties of a SiteMapNode object.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
    // Navigate the SiteMap built by the default SiteMapProvider.
    Response.Write(SiteMap.RootNode.ToString() + "<BR>");

    Response.Write(SiteMap.RootNode.Url + "<BR>");
    Response.Write(SiteMap.RootNode.Title + "<BR>");

    foreach (SiteMapNode sitemapnode in SiteMap.RootNode.ChildNodes)
        // Iterate through the ChildNodes SiteMapNodesCollection
        // maintained by the RootNode.
        Response.Write(sitemapnode.Url + "<BR>" );

    IEnumerator providers = SiteMap.Providers.GetEnumerator();
    while (providers.MoveNext())

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft