Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SiteMapNodeItemEventArgs Constructor

SiteMapNodeItemEventArgs Constructor

Initializes a new instance of the SiteMapNodeItemEventArgs class, setting the specified SiteMapNodeItem object as the source of the event.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public SiteMapNodeItemEventArgs(
	SiteMapNodeItem item
)

Parameters

item
Type: System.Web.UI.WebControls.SiteMapNodeItem

A SiteMapNodeItem that is the source of the event.

The following code example demonstrates how to create a SiteMapNodeItemEventArgs using a SiteMapNodeItem that represents a PathSeparator, and how to pass the event arguments to the OnItemCreated method. This code example is part of a larger example provided for the SiteMapPath class.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft