Class MenuItem

Base class for all menu items

Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Shell.Navigation
Assembly: EPiServer.Shell.dll
Version: 8.11.0
Syntax
public abstract class MenuItem
Examples

This example shows how to create a top level menu called "Dashboard" and sub menu item to it called "Controls".

MenuSectionItem topMenu = new MenuSectionItem("Dashboard", "/top/dashboard");
RouteMenuItem subMenu = new MenuItem("Controls","/top/dashboard/controls", "Index", new { controller = "ExampleControls", moduleArea="Shell" });

Constructors

MenuItem(String, String)

Initializes a new instance of the MenuItem class

Declaration
protected MenuItem(string text, string path)
Parameters
Type Name Description
System.String text

Text for the link

System.String path

Unique path for the menu item

Properties

Alignment

The alignment for this menu item in the menu, e.g. Right.

Declaration
public MenuItemAlignment Alignment { get; set; }
Property Value
Type Description
MenuItemAlignment

CssClass

CSS class

Declaration
public string CssClass { get; set; }
Property Value
Type Description
System.String

Depth

Get the depth of the path.

Declaration
public int Depth { get; }
Property Value
Type Description
System.Int32

ExcludeFromSearch

Gets or sets a value indicating whether this menu item should be excluded from the navigation search provider.

Declaration
public bool ExcludeFromSearch { get; set; }
Property Value
Type Description
System.Boolean

IsAvailable

The delegate responsible for determining the menuitems avaliability in a certain context.

Declaration
public Func<RequestContext, bool> IsAvailable { get; set; }
Property Value
Type Description
System.Func<System.Web.Routing.RequestContext, System.Boolean>

IsLeaf

Indicates whether this menu items has any children that should be displayed in the menu.

Declaration
public virtual bool IsLeaf { get; }
Property Value
Type Description
System.Boolean

IsStyled

Will render additional span elements used for adding icons to this menu item via style sheets

Declaration
public bool IsStyled { get; set; }
Property Value
Type Description
System.Boolean

NodeCssClass

Gets the css to apply on the li tag that encapsulates the link

Declaration
protected virtual string NodeCssClass { get; }
Property Value
Type Description
System.String

Path

Unique path for the menu item

Declaration
public string Path { get; set; }
Property Value
Type Description
System.String
Examples

/top/forum/search

SortIndex

Sort index for the menu item

Declaration
public int SortIndex { get; set; }
Property Value
Type Description
System.Int32

Target

Target frame.

Declaration
public string Target { get; set; }
Property Value
Type Description
System.String
Examples

_blank

Text

Link text

Declaration
public string Text { get; set; }
Property Value
Type Description
System.String

ToolTip

Tooltip text

Declaration
public string ToolTip { get; set; }
Property Value
Type Description
System.String

Url

The url to the interface referenced by this menu item.

Declaration
public string Url { get; set; }
Property Value
Type Description
System.String

The url for the menu item

Methods

IsSelected(RequestContext)

Determines whether the menu item is selected withing the the specified request context.

Declaration
public virtual bool IsSelected(RequestContext requestContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

Returns
Type Description
System.Boolean

RenderContents(TextWriter)

Renders the menu item contents (probably a link).

Declaration
protected virtual void RenderContents(TextWriter writer)
Parameters
Type Name Description
System.IO.TextWriter writer

The writer.

ToString()

Returns a string with the Path, Text and URL for the MenuItem

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()