RadMenuItem
Represents an item in the RadMenu control.
The RadMenu control is made up of items. Items which are immediate children of the menu are root items. Items which are children of root items are child items.
An item usually stores data in two properties, the Text property and the Value property. The value of the Textproperty is displayed in the RadMenu control, and the Value property is used to store additional data.
To create items, use one of the following methods:
- Use declarative syntax to define items inline in your page or user control.
- Use one of the constructors to dynamically create new instances of the RadMenuItem class. These items can then be added to the Items collection of another item or menu.
- Data bind the RadMenu control to a data source.
When the user clicks an item, the RadMenu control can navigate to a linked Web page, post back to the server or select that item. If the NavigateUrl property of an item is set, the RadMenu control navigates to the linked page. By default, a linked page is displayed in the same window or frame. To display the linked content in a different window or frame, use the Target property.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
public class RadMenuItem : NavigationItem, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IMarkableStateManager, IStateManager, INamingContainer, IXmlSerializable, IControlItemContainer, ICloneable, IRadMenuItemContainer
Inheritance: objectControlWebControlControlItemNavigationItemRadMenuItem...
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadMenuItem class.
public RadMenuItem()
Use this constructor to create and initialize a new instance of the RadMenuItem class using default values.
Initializes a new instance of the RadMenuItem class with the specified text and URL to navigate to.
public RadMenuItem(string text, string navigateUrl)
The text of the item. The Text property is set to the value of this parameter.
navigateUrlstringThe url which the item will navigate to. The NavigateUrl property is set to the value of this parameter.
Use this constructor to create and initialize a new instance of the RadMenuItem class using the specified text and URL.
Initializes a new instance of the RadMenuItem class with the specified text data.
public RadMenuItem(string text)
The text of the item. The Text property is set to the value of this parameter.
Use this constructor to create and initialize a new instance of the RadMenuItem class using the specified text.
Properties
Gets or sets the Cascading Style Sheet (CSS) class applied when the menu item is clicked.
public string ClickedCssClass { get; set; }
The CSS class applied when the menu item is clicked. The default value is "clicked".
Gets or sets the path to an image to display for the item when the user clicks the item.
public string ClickedImageUrl { get; set; }
The path to the image to display when the user clicks the item. The default value is empty string.
Use the ClickedImageUrl property to specify the image that will be used when the user clicks the item. If the ClickedImageUrl property is set to empty string the image specified by the ImageUrl property will be used. Use "~" (tilde) when referring to images within the current ASP.NET application.
Gets or sets the content template.
[Bindable(false)]
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(MenuItemContentTemplateContainer))]
[TemplateInstance(TemplateInstance.Single)]
public virtual ITemplate ContentTemplate { get; set; }
The content template.
Get the Content Template container of the RadMenuItem.
[Browsable(false)]
public MenuItemContentTemplateContainer ContentTemplateContainer { get; }
Gets or sets the data item represented by the item.
[Browsable(false)]
public override object DataItem { get; set; }
An object representing the data item to which the Item is bound to. The DataItem property will always return null when accessed outside of ItemDataBound event handler.
Overrides:
This property is applicable only during data binding. Use it along with the ItemDataBound event to perform additional mapping of fields from the data item to RadMenuItem properties.
Gets or sets the Cascading Style Sheet (CSS) class applied when the menu item is disabled.
public string DisabledCssClass { get; set; }
The CSS class applied when the menu item is disabled. The default value is "disabled".
By default the visual appearance of disabled menu items is defined in the skin CSS file. You can use the DisabledCssClass property to specify unique appearance for the menu item when it is disabled.
Gets or sets the path to an image to display when the items is disabled.
public string DisabledImageUrl { get; set; }
The path to the image to display when the item is disabled. The default value is empty string.
Use the DisabledImageUrl property to specify the image that will be used when the item is disabled. If the DisabledImageUrl property is set to empty string the image specified by the ImageUrl property will be used. Use "~" (tilde) when referring to images within the current ASP.NET application.
Gets or sets a value indicating whether the item image should have sprite support.
[ClientControlProperty]
[ClientPropertyName("enableImageSprite")]
public bool EnableImageSprite { get; set; }
True if the item should have sprite support; otherwise False. The default value is False.
Gets or sets the Cascading Style Sheet (CSS) class applied when the menu item is opened (its child items are visible).
public string ExpandedCssClass { get; set; }
The CSS class applied when the menu item is opened. The default value is "expanded".
By default the visual appearance of opened menu items is defined in the skin CSS file. You can use the ExpandedCssClass property to specify unique appearance for the menu item when it is opened.
Gets or sets the path to an image to display when the items is expanded.
public string ExpandedImageUrl { get; set; }
The path to the image to display when the item is expanded. The default value is empty string.
Use the ExpandedImageUrl property to specify the image that will be used when the item is expanded. If the ExpandedImageUrl property is set to empty string the image specified by the ImageUrl property will be used. Use "~" (tilde) when referring to images within the current ASP.NET application.
Gets or sets the expand behavior of the menu item.
When set to ExpandMode.WebService the RadMenuItem will populate its children from the web service specified by the RadMenu.WebService and RadMenu.WebServiceMethod properties.
public MenuItemExpandMode ExpandMode { get; set; }
On of the MenuItemExpandMode values. The default value is ClientSide.
Gets or sets the Cascading Style Sheet (CSS) class applied when the menu item is focused.
public string FocusedCssClass { get; set; }
The CSS class applied when the menu item is focused. The default value is "focused".
By default the visual appearance of focused menu items is defined in the skin CSS file. You can use the FocusedCssClass property to specify unique appearance for the menu item when it is focused.
Specifies the settings for child item behavior.
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadMenuItemGroupSettings GroupSettings { get; }
An instance of the RadMenuItemGroupSettings class.
You can customize the following settings
- item flow
- expand direction
- horizontal offset from the parent item
- vertical offset from the parent item
- width
- height
For more information check RadMenuItemGroupSettings.
protected virtual bool HasContentTemplate { get; }
Gets or sets the path to an image to display for the item when the user moves the mouse over the item.
public override string HoveredImageUrl { get; set; }
The path to the image to display when the user moves the mouse over the item. The default value is empty string.
Overrides:
Use the HoveredImageUrl property to specify the image that will be used when the user moves the mouse over the item. If the HoveredImageUrl property is set to empty string the image specified by the ImageUrl property will be used. Use "~" (tilde) when referring to images within the current ASP.NET application.
Gets or sets the path to an image to display for the item.
public override string ImageUrl { get; set; }
The path to the image to display for the item. The default value is empty string.
Overrides:
Use the ImageUrl property to specify the image for the item. If the ImageUrl property is set to empty string no image will be rendered. Use "~" (tilde) when referring to images within the current ASP.NET application.
Sets or gets whether the item is separator. It also represents a logical state of the item. Might be used in some applications for keyboard navigation to omit processing items that are marked as separators.
public bool IsSeparator { get; set; }
Gets a RadMenuItemCollection object that contains the child items of the current RadMenuItem.
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
public RadMenuItemCollection Items { get; }
A RadMenuItemCollection that contains the child items of the current RadMenuItem. By default the collection is empty (the item has no children).
Implements:
Use the Items property to access the child items of the RadMenuItem. You can also use the Items property to manage the child items - you can add, remove or modify items.
Gets or sets the template for displaying the item.
[TemplateContainer(typeof(RadMenuItem))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public ITemplate ItemTemplate { get; set; }
A ITemplate implemented object that contains the template for displaying the item. The default value is a null reference (Nothing in Visual Basic), which indicates that this property is not set.
To specify common display for all menu items use the ItemTemplate property of the RadMenu class.
Manages the item level of a particular Item instance. This property allows easy implementation/separation of the menu items in levels.
[Browsable(false)]
public int Level { get; }
Gets or sets the URL to link to when the item is clicked.
[Bindable(true)]
public override string NavigateUrl { get; set; }
The URL to link to when the item is clicked. The default value is empty string.
Overrides:
Use the NavigateUrl property to specify the URL to link to when the item is clicked. Use "~" (tilde) in front of an URL within the same ASP.NET application. When specifying external URL do not forget the protocol (e.g. "http://").
Gets or sets the Cascading Style Sheet (CSS) class applied on the outmost item element (<LI>).
public string OuterCssClass { get; set; }
The CSS class applied on the wrapping element (<LI>). The default value is empty string.
You can use the OuterCssClass property to specify unique appearance for the item.
Gets the IRadMenuItemContainer object which contains the current menu item.
[Browsable(false)]
public IRadMenuItemContainer Owner { get; }
The object which contains the menu item. It might be an instance of the RadMenu class or the RadMenuItem class depending on the hierarchy level.
Implements:
The value is of the IRadMenuItemContainer type which is implemented by the RadMenu and the RadMenuItem classes. Use the Owner property when recursively traversing items in the RadMenu control.
Gets or sets a value indicating whether clicking on the item will postback.
public bool PostBack { get; set; }
True if the menu item should postback; otherwise false. By default all the items will postback provided the user has subscribed to the ItemClick event.
If you subscribe to the ItemClick all menu items will postback. To turn off that behavior you should set the PostBack property to false. This property cannot be set in design time.
protected override IDictionary<string, string> PropertyMappings { get; }
Overrides:
Gets or sets a value indicating whether the item is selected.
public bool Selected { get; set; }
True if the item is selected; otherwise false. The default value is
false.
Only one item can be selected.
Gets or sets the Cascading Style Sheet (CSS) class applied when the item is selected.
public string SelectedCssClass { get; set; }
By default the visual appearance of selected items is defined in the skin CSS file. You can use the SelectedCssClass property to specify unique appearance for a item when it is selected.
Gets or sets a value specifying the URL of the image rendered when the item is selected.
public string SelectedImageUrl { get; set; }
If the
SelectedImageUrlproperty is not set the ImageUrl property will be used when the node is selected.
Gets or sets the Cascading Style Sheet (CSS) class that contains the sprite image for this Item and the positioning for it.
public string SpriteCssClass { get; set; }
The CSS that is used in sprite image scenarios. String.Empty.
By default, the image in an Item is defined by the ImageUrl property. You can use SpriteCssClass to specify a class that will position a sprite instead of using image. The CssClasss is applied when EnableImageSprite property is set to true.
protected override HtmlTextWriterTag TagKey { get; }
Overrides:
Gets or sets the target window or frame to display the Web page content linked to when the menu item is clicked.
[TypeConverter(typeof(TargetConverter))]
public override string Target { get; set; }
The target window or frame to load the Web page linked to when the Item is selected. Values must begin with a letter in the range of a through z (case insensitive), except for the following special values, which begin with an underscore:
The default value is empty string.
Overrides:
Use the Target property to specify the frame or window that displays the Web page linked to when the menu item is clicked. The Web page is specified by setting the NavigateUrl property.
If this property is not set, the Web page specified by the NavigateUrl property is loaded in the current window.
Gets or sets the text caption for the menu item.
public override string Text { get; set; }
The text of the item. The default value is empty string.
Overrides:
Use the Text property to specify the text to display for the item.
Methods
protected override void AddAttributesToRender(HtmlTextWriter writer)
Overrides:
Instantiates the ContentTemplate inside the Content. Clears all existing controls in the Content before that.
public void ApplyContentTemplate()
Creates a copy of the current RadMenuItem object.
public RadMenuItem Clone()
A RadMenuItem which is a copy of the current one.
Use the Clone method to create a copy of the current item. All properties of the clone are set to the same values as the current ones. Child items are not cloned.
protected override void CreateChildControls()
Overrides:
protected override ControlItemCollection CreateChildItemCollection()
Overrides:
Highlights the path from the item to the top of the menu.
public void HighlightPath()
The
HighlightPathmethod applies the "rmFocused" CSS class to the item and his ancestor items. As a results the "path" from the top level to that specific item is highlighted.
protected override void LoadFromDictionary(IDictionary<string, object> dictionary)
Overrides:
protected override void ReadXmlForChildren(XmlReader reader)
Overrides:
Removes the item from its container
public void Remove()
protected override void RenderContents(HtmlTextWriter writer)
Overrides:
protected override void SetItemContainer(ControlItemContainer itemContainer)
Overrides:
protected override void WriteXmlForChildren(XmlWriter writer)
Overrides: