SiteMapPath.OnItemCreated(SiteMapNodeItemEventArgs) 메서드

정의

컨트롤의 ItemCreated 이벤트를 발생 줍니다 SiteMapPath .

protected:
 virtual void OnItemCreated(System::Web::UI::WebControls::SiteMapNodeItemEventArgs ^ e);
protected virtual void OnItemCreated(System.Web.UI.WebControls.SiteMapNodeItemEventArgs e);
abstract member OnItemCreated : System.Web.UI.WebControls.SiteMapNodeItemEventArgs -> unit
override this.OnItemCreated : System.Web.UI.WebControls.SiteMapNodeItemEventArgs -> unit
Protected Overridable Sub OnItemCreated (e As SiteMapNodeItemEventArgs)

매개 변수

e
SiteMapNodeItemEventArgs

이벤트 데이터를 포함하는 A SiteMapNodeItemEventArgs 입니다.

예제

다음 코드 예제에서는 메서드 내에서 OnItemCreated 만든 후 메서드를 호출 SiteMapNodeItem 하는 InitializeItem 방법을 보여 줍니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 SiteMapPath 일부입니다.

private void AddDropDownListAfterCurrentNode(SiteMapNodeItem item) {

    SiteMapNodeCollection childNodes = item.SiteMapNode.ChildNodes;

    // Only do this work if there are child nodes.
    if (childNodes != null) {

        // Add another PathSeparator after the CurrentNode.
        SiteMapNodeItem finalSeparator =
            new SiteMapNodeItem(item.ItemIndex,
                                SiteMapNodeItemType.PathSeparator);

        SiteMapNodeItemEventArgs eventArgs =
            new SiteMapNodeItemEventArgs(finalSeparator);

        InitializeItem(finalSeparator);
        // Call OnItemCreated every time a SiteMapNodeItem is
        // created and initialized.
        OnItemCreated(eventArgs);

        // The pathSeparator does not bind to any SiteMapNode, so
        // do not call DataBind on the SiteMapNodeItem.
        item.Controls.Add(finalSeparator);

        // Create a DropDownList and populate it with the children of the
        // CurrentNode. There are no styles or templates that are applied
        // to the DropDownList control. If OnSelectedIndexChanged is raised,
        // the event handler redirects to the page selected.
        // The CurrentNode has child nodes.
        DropDownList ddList = new DropDownList();
        ddList.AutoPostBack = true;

        ddList.SelectedIndexChanged += new EventHandler(this.DropDownNavPathEventHandler);

        // Add a ListItem to the DropDownList for every node in the
        // SiteMapNodes collection.
        foreach (SiteMapNode node in childNodes) {
            ddList.Items.Add(new ListItem(node.Title, node.Url));
        }

        item.Controls.Add(ddList);
    }
}
Private Sub AddDropDownListAfterCurrentNode(item As SiteMapNodeItem)

   Dim childNodes As SiteMapNodeCollection = item.SiteMapNode.ChildNodes

   ' Only do this work if there are child nodes.
   If Not (childNodes Is Nothing) Then

      ' Add another PathSeparator after the CurrentNode.
      Dim finalSeparator As New SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator)

      Dim eventArgs As New SiteMapNodeItemEventArgs(finalSeparator)

      InitializeItem(finalSeparator)
      ' Call OnItemCreated every time a SiteMapNodeItem is
      ' created and initialized.
      OnItemCreated(eventArgs)

      ' The pathSeparator does not bind to any SiteMapNode, so
      ' do not call DataBind on the SiteMapNodeItem.
      item.Controls.Add(finalSeparator)

      ' Create a DropDownList and populate it with the children of the
      ' CurrentNode. There are no styles or templates that are applied
      ' to the DropDownList control. If OnSelectedIndexChanged is raised,
      ' the event handler redirects to the page selected.
      ' The CurrentNode has child nodes.
      Dim ddList As New DropDownList()
      ddList.AutoPostBack = True

      AddHandler ddList.SelectedIndexChanged, AddressOf Me.DropDownNavPathEventHandler

      ' Add a ListItem to the DropDownList for every node in the
      ' SiteMapNodes collection.
      Dim node As SiteMapNode
      For Each node In  childNodes
         ddList.Items.Add(New ListItem(node.Title, node.Url))
      Next node

      item.Controls.Add(ddList)
   End If
End Sub

설명

이벤트는 컨트롤이 해당 컨트롤을 나타내는 웹 서버 컨트롤인 />를 만들고 연결한 후에 발생합니다. OnItemCreated 생성된 노드 항목이 해당 데이터에 바인딩되기 전에 메서드가 호출됩니다. 이렇게 하면 만들 때마다 사용자 지정 루틴을 수행하는 이벤트 처리 메서드를 SiteMapNodeItem 제공할 수 있습니다.

이벤트를 발생시키는 경우 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생을 참조하세요.

또한 이 OnItemCreated 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 파생 클래스에서 이벤트를 처리하기 위한 기본 설정 기술입니다.

상속자 참고

파생 클래스에서 재정의하는 OnItemCreated(SiteMapNodeItemEventArgs) 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnItemCreated(SiteMapNodeItemEventArgs) 메서드를 호출해야 합니다.

적용 대상

추가 정보