SiteMapNode.ToString 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 SiteMapNode 类的此实例的值转换为其等效的字符串表示形式。
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
返回
此 SiteMapNode 的值的字符串表示形式。
示例
下面的代码示例演示如何将 方法与 Url 对象的 和 Title 属性SiteMapNode进行比较ToString。
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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())
{
Response.Write(providers.Current);
Response.Write(" ");
Response.Write("<BR>");
}
}
</SCRIPT>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT runat="server">
Private Sub Page_Load(Sender As Object, E As EventArgs)
' 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>")
Dim sitemapnode As SiteMapNode
For Each sitemapnode In SiteMap.RootNode.ChildNodes
' Iterate through the ChildNodes SiteMapNodesCollection
' maintained by the RootNode.
Response.Write(sitemapnode.Url & "<BR>" )
Next
Dim providers As IDictionaryEnumerator = SiteMap.Providers.GetEnumerator()
While (providers.MoveNext())
Response.Write(providers.Current)
Response.Write(" ")
Response.Write("<BR>")
End While
End Sub ' Page_Load
</SCRIPT>
注解
方法 ToString 返回 Title 对象的 属性 SiteMapNode 。