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입니다.

예제

다음 코드 예제에서는 처리 하는 방법에 설명 합니다 SiteMapResolve 이벤트와 같은 사이트 탐색 컨트롤에 의해 표시 되는 대상 Url을 수정 하는 ASP.NET 웹 페이지에는 SiteMapPath 컨트롤입니다. 이 예제에서는 현재 페이지의 온라인 게시판 또는 포럼 게시물 페이지입니다. 보다 의미 있는 렌더링 하기 위해 사이트 탐색, 탐색 컨트롤에 의해 표시 되는 노드의 Url 컨텍스트에 관련 된 쿼리 문자열을 사용 하 여 추가 됩니다.

참고

안전 하 게 액세스 하는 것을 CurrentNode 내에서 속성을 SiteMapResolveEventHandler 클래스. 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)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보