asp.net.ph

MenuItem.Parent Property

System.Web.UI.WebControls Namespace   MenuItem Class


.NET Framework version 2.0

Returns the parent MenuItem of the current menu item.

Syntax


Script [ MenuItem menuItem = ] MenuItem.Parent

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


menuItem A MenuItem object that represents the parent of the current menu item.

The property is read only with no default value.

Remarks

Use the Parent property to determine the parent of the current menu item or to access the parent menu item's properties.

NOTE: A root menu item does not have a parent menu item.

To access the submenu items of the current menu item, use the ChildItems property.

Example

The following example demonstrates how to use the Parent property to access the properties of the current menu item's parent node.

void getSelectedValues ( Object source, MenuEventArgs e ) {
   // e.Item refers to the MenuItem that caused the event
   // which refers to the same MenuItem object returned when using Menu.SelectedItem

   // Here we use both properties to illustrate the concept
   // and to simply display the values of the Text and Value properties
   // associated with the selected menu item and its parent

   message.Text = "<p>Selected MenuItem Text: <b>" + e.Item.Text + "</b><br>" +
      "Selected MenuItem Value: <b>" + catalogsMenu.SelectedValue + "</b>";

   if ( e.Item.Parent != null )
      message.Text += "<p>Selected MenuItem's Parent Text: <b>" + e.Item.Parent.Text + "</b><br>" +
         "Selected MenuItem's Parent Value: <b>" + catalogsMenu.SelectedItem.Parent.Value + "</b>";
   else
      message.Text += "<p>The selected item is a root menu item that does not have a parent.";

}
  C# VB

 Show me 

See Also

MenuItem Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph