SiteMap.SiteMapResolve イベント
アセンブリ: System.Web (system.web.dll 内)

public: static event SiteMapResolveEventHandler^ SiteMapResolve { void add (SiteMapResolveEventHandler^ value); void remove (SiteMapResolveEventHandler^ value); }

サブスクライバは、SiteMapResolveEventHandler オブジェクトを静的イベント SiteMapResolve に割り当て、CurrentNode プロパティがアクセスされたときに通知を受信します。これにより、現在実行中のページの SiteMapNode 表現を作成する場合、カスタム プロバイダの実装を必要とせずにカスタム ロジックを実装できます。
SiteMapResolve イベントをサブスクライブする場合は、既定のサイト マップ プロバイダの SiteMapResolve イベントもサブスクライブします。

SiteMapResolve イベントを ASP.NET Web ページで処理して、SiteMapPath コントロールなどのサイト ナビゲーション コントロールにより表示される URL を変更する方法を示すコード例を次に示します。この例では、現在のページはオンラインの掲示板またはフォーラムの投稿ページです。より意味のあるサイト ナビゲーションを実現するため、ナビゲーション コントロールにより表示されるノードの URL が、コンテキストに関連するクエリ文字列に付加されます。
![]() |
---|
ASP.NET サイト ナビゲーション インフラストラクチャは、無限再帰を防ぎます。これが保護手段となり、CurrentNode プロパティを SiteMapResolveEventHandlerclass の中からアクセスすることに関連するセキュリティ リスクを最小限に抑えます。 |
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSiteMap.SiteMapResolve イベントを検索する場合は、下記のリンクをクリックしてください。

- SiteMap.SiteMapResolve イベントのページへのリンク