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 值的字串表示。
範例
下列程式碼範例示範如何比較 ToString 方法與 Url 物件的 和 Title 屬性 SiteMapNode 。
<%@ 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 。