This documentation is archived and is not being maintained.

Menu.PathSeparator Property

Gets or sets the character used to delimit the path of a menu item in a Menu control.

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

public char PathSeparator { get; set; }
<asp:Menu PathSeparator="Char" />

Property Value

Type: System.Char
The character used to delimit the path of a menu item. The default value is a slash mark (/).

Each menu item (represented by a MenuItem object) in the Menu control has a ValuePath property that specifies the position of the menu item. The value path is a string of delimited values that form the path from a root menu item to the current menu item. Use the PathSeparator property to specify the delimiting character used to separate the values in the menu path. This value is commonly used when parsing the list for the individual values.

Depending on the text displayed in the Menu control, the delimiter character might need to be changed to prevent any conflicts. For example, if you set the delimiter character to a comma, the displayed text should not contain any commas; otherwise, the ValuePath property cannot be parsed accurately.

The following code example demonstrates how to use the PathSeparator property to change the delimiter character for a menu item's value path to a comma.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<script runat="server">

  void Page_Load(Object sender, EventArgs e)
    // The value path for a menu item is a delimited list 
    // of menu text values that form a path from the root  
    // menu item to the current menu item. 

    // Declare the value path to the Classical menu item using 
    // the delimiter character specified in the PathSeparator 
    // property. In this example, the delimiter character is a 
    // comma.
    String valuePath = "Home,Music,Classical";

    // Use the FindItem method to get the Classical menu item using 
    // its value path.
    MenuItem item = NavigationMenu.FindItem(valuePath);

    // Indicate whether the menu item was found. 
    if (item != null)
      Message.Text = item.Text + " menu item found at depth " + 
        item.Depth.ToString() + ".";
      Message.Text = "Menu item not found.";


<html xmlns="" >
  <head runat="server">
    <title>Menu PathSeparator and FindItem Example</title>
    <form id="form1" runat="server">

      <h3>Menu PathSeparator and FindItem Example</h3>

      <!-- Use the PathSeparator property to  -->
      <!-- change the delimiter character for -->
      <!-- the value path of a menu item to a -->
      <!-- comma (,).                         -->
      <asp:menu id="NavigationMenu"

          <asp:menuitem text="Home"
            <asp:menuitem text="Music"
              <asp:menuitem text="Classical"
              <asp:menuitem text="Rock"
              <asp:menuitem text="Jazz"
            <asp:menuitem text="Movies"
              <asp:menuitem text="Action"
              <asp:menuitem text="Drama"
              <asp:menuitem text="Musical"



      <asp:label id="Message" 


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0