SiteMapResolveEventHandler デリゲート
アセンブリ: System.Web (system.web.dll 内)

Public Delegate Function SiteMapResolveEventHandler ( _ sender As Object, _ e As SiteMapResolveEventArgs _ ) As SiteMapNode
public delegate SiteMapNode^ SiteMapResolveEventHandler ( Object^ sender, SiteMapResolveEventArgs^ e )
/** @delegate */ public delegate SiteMapNode SiteMapResolveEventHandler ( Object sender, SiteMapResolveEventArgs e )
戻り値
SiteMapResolveEventHandler 操作の結果を表す SiteMapNode。

静的クラス SiteMap は、既定のサイト マップ プロバイダのSiteMapResolve イベントを公開します。
SqlDataSourceCommandEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「イベントとデリゲート」を参照してください。

SiteMapResolve イベントを ASP.NET Web ページで処理して、SiteMapPath コントロールなどのサイト ナビゲーション コントロールにより表示される URL を変更する方法を示したコード例を次に示します。この例では、現在のページはオンラインの掲示板またはフォーラムの投稿ページです。より意味のあるサイト ナビゲーションを実現するため、ナビゲーション コントロールにより表示されるノードの URL が、コンテキストに関連するクエリ文字列に付加されます。
![]() |
---|
CurrentNode プロパティに SiteMapResolveEventHandler クラスの中からアクセスしても安全です。この場合、ASP.NET サイト ナビゲーション インフラストラクチャが無限の再帰を防ぎます。 |
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' The ExpandForumPaths method is called to handle ' the SiteMapResolve event. AddHandler SiteMap.SiteMapResolve, AddressOf Me.ExpandForumPaths End Sub Private Function ExpandForumPaths(ByVal sender As Object, ByVal e As SiteMapResolveEventArgs) As SiteMapNode ' The current node represents a Post page in a bulletin board forum. ' Clone the current node and all of its relevant parents. This ' returns a site map node that a developer can then ' walk, modifying each node.Url property in turn. ' Since the cloned nodes are separate from the underlying ' site navigation structure, the fixups that are made do not ' effect the overall site navigation structure. Dim currentNode As SiteMapNode = SiteMap.CurrentNode.Clone(True) Dim tempNode As SiteMapNode = currentNode ' Obtain the recent IDs. Dim forumGroupID As Integer = GetMostRecentForumGroupID() Dim forumID As Integer = GetMostRecentForumID(forumGroupID) Dim postID As Integer = GetMostRecentPostID(forumID) ' The current node, and its parents, can be modified to include ' dynamic querystring information relevant to the currently ' executing request. If Not (0 = postID) Then tempNode.Url = tempNode.Url & "?PostID=" & postID.ToString() End If tempNode = tempNode.ParentNode If Not (0 = forumID) And Not (tempNode Is Nothing) Then tempNode.Url = tempNode.Url & "?ForumID=" & forumID.ToString() End If tempNode = tempNode.ParentNode If Not (0 = ForumGroupID) And Not (tempNode Is Nothing) Then tempNode.Url = tempNode.Url & "?ForumGroupID=" & forumGroupID.ToString() End If Return currentNode End Function
private void Page_Load(object sender, EventArgs e) { // The ExpandForumPaths method is called to handle // the SiteMapResolve event. SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(this.ExpandForumPaths); } private SiteMapNode ExpandForumPaths(Object sender, SiteMapResolveEventArgs e) { // The current node represents a Post page in a bulletin board forum. // Clone the current node and all of its relevant parents. This // returns a site map node that a developer can then // walk, modifying each node.Url property in turn. // Since the cloned nodes are separate from the underlying // site navigation structure, the fixups that are made do not // effect the overall site navigation structure. SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true); SiteMapNode tempNode = currentNode; // Obtain the recent IDs. int forumGroupID = GetMostRecentForumGroupID(); int forumID = GetMostRecentForumID(forumGroupID); int postID = GetMostRecentPostID(forumID); // The current node, and its parents, can be modified to include // dynamic querystring information relevant to the currently // executing request. if (0 != postID) { tempNode.Url = tempNode.Url + "?PostID=" + postID.ToString(); } if ((null != (tempNode = tempNode.ParentNode)) && (0 != forumID)) { tempNode.Url = tempNode.Url + "?ForumID=" + forumID.ToString(); } if ((null != (tempNode = tempNode.ParentNode)) && (0 != forumGroupID)) { tempNode.Url = tempNode.Url + "?ForumGroupID=" + forumGroupID.ToString(); } return currentNode; }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SiteMapResolveEventHandler デリゲートのページへのリンク