SiteMapResolveEventHandler 代理人

定義

クラス SiteMapResolve または静的クラス SiteMapProvider のインスタンスによる SiteMap イベントを処理するメソッドを表します。

public delegate System::Web::SiteMapNode ^ SiteMapResolveEventHandler(System::Object ^ sender, SiteMapResolveEventArgs ^ e);
public delegate System.Web.SiteMapNode SiteMapResolveEventHandler(object sender, SiteMapResolveEventArgs e);
type SiteMapResolveEventHandler = delegate of obj * SiteMapResolveEventArgs -> SiteMapNode
Public Delegate Function SiteMapResolveEventHandler(sender As Object, e As SiteMapResolveEventArgs) As SiteMapNode 

パラメーター

sender
Object

イベント ソースである、SiteMapProvider クラスのインスタンス。

e
SiteMapResolveEventArgs

イベント データを格納している SiteMapResolveEventArgs

戻り値

SiteMapNode 操作の結果を表す SiteMapResolveEventHandler

次のコード例では、ASP.NET Web ページでイベントを SiteMapResolve 処理して、サイト ナビゲーション コントロールによって表示されるターゲット URL (コントロールなど) を変更する方法を SiteMapPath 示します。 この例では、現在のページはオンライン掲示板またはフォーラムの投稿ページです。 より意味のあるサイト ナビゲーションをレンダリングするために、ナビゲーション コントロールによって表示されるノードの URL に、コンテキストに関連するクエリ文字列が追加されます。

Note

クラス内SiteMapResolveEventHandlerから プロパティにCurrentNodeアクセスしても安全です。 この場合、ASP.NET サイト ナビゲーション インフラストラクチャは無限再帰から保護します。

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;
}
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

注釈

静的 SiteMap クラスは、既定の SiteMapResolve サイト マップ プロバイダーのイベントを公開します。

SqlDataSourceCommandEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを指定します。 イベント ハンドラーにイベントを関連付けるには、イベントにデリゲートのインスタンスを追加します。 イベント ハンドラーは、デリゲートを削除しない限り、イベントが発生するたびに呼び出されます。 イベント ハンドラー デリゲートの詳細については、「イベントの 処理と発生」を参照してください。

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください