SiteMapResolveEventArgs Kelas

Definisi

Menyediakan data untuk peristiwa yang dimunculkan dengan memanggil CurrentNode properti SiteMapProvider kelas .

public ref class SiteMapResolveEventArgs : EventArgs
public class SiteMapResolveEventArgs : EventArgs
type SiteMapResolveEventArgs = class
    inherit EventArgs
Public Class SiteMapResolveEventArgs
Inherits EventArgs
Warisan
SiteMapResolveEventArgs

Contoh

Contoh kode berikut menunjukkan cara menangani SiteMapResolve peristiwa pada halaman web ASP.NET untuk mengubah URL target yang ditampilkan oleh kontrol navigasi situs, seperti SiteMapPath kontrol. Dalam contoh ini, halaman saat ini adalah halaman postingan di papan buletin online atau forum. Untuk merender navigasi situs yang lebih bermakna, URL simpul yang ditampilkan oleh kontrol navigasi ditambahkan dengan string kueri yang relevan dengan konteks.

Catatan Anda dapat mengakses CurrentNode properti dari dalam SiteMapResolveEventHandler kelas dengan aman. Infrastruktur navigasi situs ASP.NET melindungi dari rekursi tak terbatas, dalam hal ini.

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

Keterangan

Kelas SiteMapResolveEventArgs digunakan dalam ResolveSiteMapNode metode untuk memungkinkan pelanggan ke SiteMapResolve peristiwa untuk mengembalikan instans SiteMapNode kelas. Dengan menambahkan delegasi penanganan aktivitas untuk menangani SiteMapResolve acara, Anda dapat membuat SiteMapNode representasi halaman tanpa menerapkan penyedia peta situs kustom.

Konstruktor

SiteMapResolveEventArgs(HttpContext, SiteMapProvider)

Menginisialisasi instans SiteMapResolveEventArgs baru kelas menggunakan objek dan SiteMapProvider yang ditentukanHttpContext.

Properti

Context

Mendapatkan konteks permintaan halaman yang diwakili simpul yang diminta.

Provider

SiteMapProvider Mendapatkan objek yang menaikkan SiteMapResolve peristiwa.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga