MenuItem 생성자

정의

MenuItem 클래스의 새 인스턴스를 초기화합니다.

오버로드

MenuItem()

메뉴 텍스트나 값을 사용하지 않고 MenuItem 클래스의 새 인스턴스를 초기화합니다.

MenuItem(String)

지정한 메뉴 텍스트를 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

MenuItem(String, String)

지정한 메뉴 텍스트와 값을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

MenuItem(String, String, String)

지정한 메뉴 텍스트, 값 및 이미지 URL을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

MenuItem(String, String, String, String)

지정한 메뉴 텍스트, 값, 이미지 URL 및 탐색 URL을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

MenuItem(String, String, String, String, String)

메뉴 텍스트, 값, 이미지 URL, 탐색 URL 및 대상을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

MenuItem()

메뉴 텍스트나 값을 사용하지 않고 MenuItem 클래스의 새 인스턴스를 초기화합니다.

public:
 MenuItem();
public MenuItem ();
Public Sub New ()

예제

다음 예제에서는의 새 인스턴스를 만들려면이 생성자를 사용 하는 방법에 설명 합니다 MenuItem 클래스입니다. 합니다 MenuItem 개체는 동적으로 메뉴 항목을 채우는 데 다음을 Menu 제어 합니다.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  void Page_Load(Object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      // Create the menu structure.

      // Create the root menu item.
      MenuItem homeMenuItem;
      homeMenuItem = CreateMenuItem("Home", "Home.aspx", "Home");

      // Create the submenu items.
      MenuItem musicSubMenuItem;
      musicSubMenuItem = CreateMenuItem("Music", "Music.aspx", "Music");

      MenuItem moviesSubMenuItem;
      moviesSubMenuItem = CreateMenuItem("Movies", "Movies.aspx", "Movies");

      // Add the submenu items to the ChildItems
      // collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem);
      homeMenuItem.ChildItems.Add(moviesSubMenuItem);

      // Add the root menu item to the Items collection 
      // of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem);
    }
  }
  
  MenuItem CreateMenuItem(String text, String url, String toolTip)
  {
    
    // Create a new MenuItem object.
    MenuItem menuItem = new MenuItem();
    
    // Set the properties of the MenuItem object using
    // the specified parameters.
    menuItem.Text = text;
    menuItem.NavigateUrl = url;
    menuItem.ToolTip = toolTip;
    
    return menuItem;
    
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    If Not IsPostBack Then
      
      ' Create the menu structure.
    
      ' Create the root menu item.
      Dim homeMenuItem As MenuItem
      homeMenuItem = CreateMenuItem("Home", "Home.aspx", "Home")
    
      ' Create the submenu items.
      Dim musicSubMenuItem As MenuItem
      musicSubMenuItem = CreateMenuItem("Music", "Music.aspx", "Music")
    
      Dim moviesSubMenuItem As MenuItem
      moviesSubMenuItem = CreateMenuItem("Movies", "Movies.aspx", "Movies")
    
      ' Add the submenu items to the ChildItems
      ' collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem)
      homeMenuItem.ChildItems.Add(moviesSubMenuItem)
    
      ' Add the root menu item to the Items collection 
      ' of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem)
      
    End If
    
  End Sub
  
  Function CreateMenuItem(ByVal text As String, ByVal url As String, ByVal toolTip As String) As MenuItem
    
    ' Create a new MenuItem object.
    Dim menuItem As New MenuItem()
    
    ' Set the properties of the MenuItem object using
    ' the specified parameters.
    MenuItem.Text = text
    MenuItem.NavigateUrl = url
    MenuItem.ToolTip = toolTip
    
    Return MenuItem
    
  End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

설명

이 생성자의 새 인스턴스를 사용 하는 MenuItem 메뉴 텍스트나 값을 사용 하지 않고 클래스입니다.

참고

이 생성자를 사용 하는 경우, 모든 속성에는 MenuItem 개체가 기본값으로 설정 됩니다. 개체를 만든 후 필요에 따라 속성을 설정 해야 합니다.

동적으로 채울 때이 생성자는 일반적으로 사용 됩니다는 Items 의 컬렉션을 Menu 컨트롤 또는 ChildItems 의 컬렉션을 MenuItem 개체입니다.

추가 정보

적용 대상

MenuItem(String)

지정한 메뉴 텍스트를 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

public:
 MenuItem(System::String ^ text);
public MenuItem (string text);
new System.Web.UI.WebControls.MenuItem : string -> System.Web.UI.WebControls.MenuItem
Public Sub New (text As String)

매개 변수

text
String

Menu 컨트롤의 메뉴 항목에 표시되는 텍스트입니다.

예제

다음 예제에서는의 새 인스턴스를 만들려면이 생성자를 사용 하는 방법에 설명 합니다 MenuItem 클래스입니다. 합니다 MenuItem 개체는 동적으로 메뉴 항목을 채우는 데 다음을 Menu 제어 합니다.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  void Page_Load(Object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      // Create the menu structure.

      // Create the root menu item.
      MenuItem homeMenuItem = new MenuItem("Home");

      // Create the submenu items.
      MenuItem musicSubMenuItem = new MenuItem("Music");
      MenuItem moviesSubMenuItem = new MenuItem("Movies");

      // Add the submenu items to the ChildItems
      // collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem);
      homeMenuItem.ChildItems.Add(moviesSubMenuItem);

      // Add the root menu item to the Items collection 
      // of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem);
    }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    If Not IsPostBack Then
    
      ' Create the menu structure.

      ' Create the root menu item.
      Dim homeMenuItem As New MenuItem("Home")

      ' Create the submenu items.
      Dim musicSubMenuItem As New MenuItem("Music")
      Dim moviesSubMenuItem As New MenuItem("Movies")

      ' Add the submenu items to the ChildItems
      ' collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem)
      homeMenuItem.ChildItems.Add(moviesSubMenuItem)

      ' Add the root menu item to the Items collection 
      ' of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem)
      
    End If
  
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 MenuItem 변수로 지정한 메뉴 텍스트를 사용 하 여 클래스를 text 매개 변수입니다.

다음 표에서 인스턴스에 대 한 초기 속성 값을 MenuItem 클래스입니다.

속성 초기 값
Text Text 매개 변수의 값입니다.

동적으로 채울 때이 생성자는 일반적으로 사용 됩니다는 Items 의 컬렉션을 Menu 컨트롤 또는 ChildItems 의 컬렉션을 MenuItem 개체입니다.

추가 정보

적용 대상

MenuItem(String, String)

지정한 메뉴 텍스트와 값을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

public:
 MenuItem(System::String ^ text, System::String ^ value);
public MenuItem (string text, string value);
new System.Web.UI.WebControls.MenuItem : string * string -> System.Web.UI.WebControls.MenuItem
Public Sub New (text As String, value As String)

매개 변수

text
String

Menu 컨트롤의 메뉴 항목에 표시되는 텍스트입니다.

value
String

포스트백 이벤트 처리에 사용되는 데이터 같이 메뉴 항목과 연결된 추가 데이터입니다.

예제

다음 예제에서는의 새 인스턴스를 만들려면이 생성자를 사용 하는 방법에 설명 합니다 MenuItem 클래스입니다. 합니다 MenuItem 개체는 동적으로 메뉴 항목을 채우는 데 다음을 Menu 제어 합니다.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  void Page_Load(Object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      // Create the menu structure.

      // Create the root menu item.
      MenuItem homeMenuItem = new MenuItem("Home", "Root");

      // Create the submenu items.
      MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1");
      MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2");

      // Add the submenu items to the ChildItems
      // collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem);
      homeMenuItem.ChildItems.Add(moviesSubMenuItem);

      // Add the root menu item to the Items collection 
      // of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem);
    }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    If Not IsPostBack Then
    
      ' Create the menu structure.

      ' Create the root menu item.
      Dim homeMenuItem As New MenuItem("Home", "Root")

      ' Create the submenu items.
      Dim musicSubMenuItem As New MenuItem("Music", "Category 1")
      Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2")

      ' Add the submenu items to the ChildItems
      ' collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem)
      homeMenuItem.ChildItems.Add(moviesSubMenuItem)

      ' Add the root menu item to the Items collection 
      ' of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem)
      
    End If
  
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 MenuItem 메뉴 텍스트와 지정 된 값을 사용 하 여 클래스를 textvalue 매개 변수를 각각.

다음 표에서는 MenuItem 클래스의 인스턴스에 대한 초기 속성 값을 보여 줍니다.

속성 초기 값
Text text 매개 변수의 값입니다.
Value value 매개 변수의 값입니다.

동적으로 채울 때이 생성자는 일반적으로 사용 됩니다는 Items 의 컬렉션을 Menu 컨트롤 또는 ChildItems 의 컬렉션을 MenuItem 개체입니다.

추가 정보

적용 대상

MenuItem(String, String, String)

지정한 메뉴 텍스트, 값 및 이미지 URL을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

public:
 MenuItem(System::String ^ text, System::String ^ value, System::String ^ imageUrl);
public MenuItem (string text, string value, string imageUrl);
new System.Web.UI.WebControls.MenuItem : string * string * string -> System.Web.UI.WebControls.MenuItem
Public Sub New (text As String, value As String, imageUrl As String)

매개 변수

text
String

Menu 컨트롤의 메뉴 항목에 표시되는 텍스트입니다.

value
String

포스트백 이벤트 처리에 사용되는 데이터 같이 메뉴 항목과 연결된 추가 데이터입니다.

imageUrl
String

메뉴 항목의 텍스트 옆에 표시되는 이미지의 URL입니다.

예제

다음 예제에서는의 새 인스턴스를 만들려면이 생성자를 사용 하는 방법에 설명 합니다 MenuItem 클래스입니다. 합니다 MenuItem 개체는 동적으로 메뉴 항목을 채우는 데 다음을 Menu 제어 합니다.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  void Page_Load(Object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      // Create the menu structure.

      // Create the root menu item.
      MenuItem homeMenuItem = new MenuItem("Home", "Root", 
        @"Images\Home.jpg");

      // Create the submenu items.
      MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1", 
        @"Images\Music.jpg");
      MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2", 
        @"Images\Movies.jpg");

      // Add the submenu items to the ChildItems
      // collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem);
      homeMenuItem.ChildItems.Add(moviesSubMenuItem);

      // Add the root menu item to the Items collection 
      // of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem);
    }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    If Not IsPostBack Then
    
      ' Create the menu structure.

      ' Create the root menu item.
      Dim homeMenuItem As New MenuItem("Home", "Root", _
        "Images\Home.jpg")

      ' Create the submenu items.
      Dim musicSubMenuItem As New MenuItem("Music", "Category 1", _
        "Images\Music.jpg")
      Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2", _
        "Images\Movies.jpg")

      ' Add the submenu items to the ChildItems
      ' collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem)
      homeMenuItem.ChildItems.Add(moviesSubMenuItem)

      ' Add the root menu item to the Items collection 
      ' of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem)
      
    End If
  
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 MenuItem 메뉴 텍스트, 값을 사용 하 여 클래스 및 지정 된 URL 이미지를 textvalue, 및 imageUrl 매개 변수를 각각.

다음 표에서는 MenuItem 클래스의 인스턴스에 대한 초기 속성 값을 보여 줍니다.

속성 초기 값
Text text 매개 변수의 값입니다.
Value value 매개 변수의 값입니다.
ImageUrl imageUrl 매개 변수의 값입니다.

동적으로 채울 때이 생성자는 일반적으로 사용 됩니다는 Items 의 컬렉션을 Menu 컨트롤 또는 ChildItems 의 컬렉션을 MenuItem 개체입니다.

추가 정보

적용 대상

MenuItem(String, String, String, String)

지정한 메뉴 텍스트, 값, 이미지 URL 및 탐색 URL을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

public:
 MenuItem(System::String ^ text, System::String ^ value, System::String ^ imageUrl, System::String ^ navigateUrl);
public MenuItem (string text, string value, string imageUrl, string navigateUrl);
new System.Web.UI.WebControls.MenuItem : string * string * string * string -> System.Web.UI.WebControls.MenuItem
Public Sub New (text As String, value As String, imageUrl As String, navigateUrl As String)

매개 변수

text
String

Menu 컨트롤의 메뉴 항목에 표시되는 텍스트입니다.

value
String

포스트백 이벤트 처리에 사용되는 데이터 같이 메뉴 항목과 연결된 추가 데이터입니다.

imageUrl
String

메뉴 항목의 텍스트 옆에 표시되는 이미지의 URL입니다.

navigateUrl
String

메뉴 항목을 클릭할 때 링크할 URL입니다.

예제

다음 예제에서는의 새 인스턴스를 만들려면이 생성자를 사용 하는 방법에 설명 합니다 MenuItem 클래스입니다. 합니다 MenuItem 개체는 동적으로 메뉴 항목을 채우는 데 다음을 Menu 제어 합니다.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  void Page_Load(Object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      // Create the menu structure.

      // Create the root menu item.
      MenuItem homeMenuItem = new MenuItem("Home", "Root",
        @"Images\Home.jpg", "Home.aspx");

      // Create the submenu items.
      MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1",
        @"Images\Music.jpg", "Music.aspx");
      MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2",
        @"Images\Movies.jpg", "Movies.aspx");

      // Add the submenu items to the ChildItems
      // collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem);
      homeMenuItem.ChildItems.Add(moviesSubMenuItem);

      // Add the root menu item to the Items collection 
      // of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem);
    }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    If Not IsPostBack Then
    
      ' Create the menu structure.

      ' Create the root menu item.
      Dim homeMenuItem As New MenuItem("Home", "Root", _
        "Images\Home.jpg", "Home.aspx")

      ' Create the submenu items.
      Dim musicSubMenuItem As New MenuItem("Music", "Category 1", _
        "Images\Music.jpg", "Music.aspx")
      Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2", _
        "Images\Movies.jpg", "Movies.aspx")

      ' Add the submenu items to the ChildItems
      ' collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem)
      homeMenuItem.ChildItems.Add(moviesSubMenuItem)

      ' Add the root menu item to the Items collection 
      ' of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem)
      
    End If
  
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 MenuItem 메뉴 텍스트, 값, 이미지 URL 및 지정 된 탐색 URL을 사용 하 여 클래스를 textvalue, imageUrl, 및 navigateUrl 매개 변수를 각각.

다음 표에서는 MenuItem 클래스의 인스턴스에 대한 초기 속성 값을 보여 줍니다.

속성 초기 값
Text text 매개 변수의 값입니다.
Value value 매개 변수의 값입니다.
ImageUrl imageUrl 매개 변수의 값입니다.
NavigateUrl navigateUrl 매개 변수의 값입니다.

동적으로 채울 때이 생성자는 일반적으로 사용 됩니다는 Items 의 컬렉션을 Menu 컨트롤 또는 ChildItems 의 컬렉션을 MenuItem 개체입니다.

추가 정보

적용 대상

MenuItem(String, String, String, String, String)

메뉴 텍스트, 값, 이미지 URL, 탐색 URL 및 대상을 사용하여 MenuItem 클래스의 새 인스턴스를 초기화합니다.

public:
 MenuItem(System::String ^ text, System::String ^ value, System::String ^ imageUrl, System::String ^ navigateUrl, System::String ^ target);
public MenuItem (string text, string value, string imageUrl, string navigateUrl, string target);
new System.Web.UI.WebControls.MenuItem : string * string * string * string * string -> System.Web.UI.WebControls.MenuItem
Public Sub New (text As String, value As String, imageUrl As String, navigateUrl As String, target As String)

매개 변수

text
String

Menu 컨트롤의 메뉴 항목에 표시되는 텍스트입니다.

value
String

포스트백 이벤트 처리에 사용되는 데이터 같이 메뉴 항목과 연결된 추가 데이터입니다.

imageUrl
String

메뉴 항목의 텍스트 옆에 표시되는 이미지의 URL입니다.

navigateUrl
String

메뉴 항목을 클릭할 때 링크할 URL입니다.

target
String

메뉴 항목을 클릭할 때 메뉴 항목에 연결된 웹 페이지 콘텐츠를 표시할 대상 창 또는 프레임입니다.

예제

다음 예제에서는의 새 인스턴스를 만들려면이 생성자를 사용 하는 방법에 설명 합니다 MenuItem 클래스입니다. 합니다 MenuItem 개체는 동적으로 메뉴 항목을 채우는 데 다음을 Menu 제어 합니다.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  void Page_Load(Object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      // Create the menu structure.

      // Create the root menu item.
      MenuItem homeMenuItem = new MenuItem("Home", "Root",
        @"Images\Home.jpg", "Home.aspx", "_self");

      // Create the submenu items.
      MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1",
        @"Images\Music.jpg", "Music.aspx", "_blank");
      MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2",
        @"Images\Movies.jpg", "Movies.aspx", "_blank");

      // Add the submenu items to the ChildItems
      // collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem);
      homeMenuItem.ChildItems.Add(moviesSubMenuItem);

      // Add the root menu item to the Items collection 
      // of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem);
    }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    If Not IsPostBack Then
    
      ' Create the menu structure.

      ' Create the root menu item.
      Dim homeMenuItem As New MenuItem("Home", "Root", _
        "Images\Home.jpg", "Home.aspx", "_self")

      ' Create the submenu items.
      Dim musicSubMenuItem As New MenuItem("Music", "Category 1", _
        "Images\Music.jpg", "Music.aspx", "_blank")
      Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2", _
        "Images\Movies.jpg", "Movies.aspx", "_blank")

      ' Add the submenu items to the ChildItems
      ' collection of the root menu item.
      homeMenuItem.ChildItems.Add(musicSubMenuItem)
      homeMenuItem.ChildItems.Add(moviesSubMenuItem)

      ' Add the root menu item to the Items collection 
      ' of the Menu control.
      NavigationMenu.Items.Add(homeMenuItem)
      
    End If
  
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItem Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItem Constructor Example</h3>
    
      <asp:menu id="NavigationMenu"
        orientation="Vertical"
        target="_blank" 
        runat="server"/>

    </form>
  </body>
</html>

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 MenuItem 메뉴 텍스트, 값, 이미지 URL, 탐색 URL 및 대상으로 지정 된 클래스를 text, value, imageUrl, navigateUrl, 및 target 매개 변수 각각.

다음 표에서는 MenuItem 클래스의 인스턴스에 대한 초기 속성 값을 보여 줍니다.

속성 초기 값
Text text 매개 변수의 값입니다.
Value value 매개 변수의 값입니다.
ImageUrl imageUrl 매개 변수의 값입니다.
NavigateUrl navigateUrl 매개 변수의 값입니다.
Target target 매개 변수의 값입니다.

동적으로 채울 때이 생성자는 일반적으로 사용 됩니다는 Items 의 컬렉션을 Menu 컨트롤 또는 ChildItems 의 컬렉션을 MenuItem 개체입니다.

추가 정보

적용 대상