MenuItem 생성자

정의

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

오버로드

Name Description
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 기본값으로 설정됩니다. 개체를 만든 후 필요에 따라 속성을 설정해야 합니다.

이 생성자는 컨트롤의 컬렉션 또는 ItemsMenu 개체 컬렉션을 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 텍스트 매개 변수의 값입니다.

이 생성자는 컨트롤의 컬렉션 또는 ItemsMenu 개체 컬렉션을 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 .

이 생성자는 컨트롤의 컬렉션 또는 ItemsMenu 개체 컬렉션을 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>

설명

이 생성자를 사용하여 각각 , 및 매개 변수로 지정된 메뉴 텍스트, 값 및 이미지 URL을 사용하여 클래스의 새 인스턴스 MenuItemtextvalueimageUrl 만듭니다.

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

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

이 생성자는 컨트롤의 컬렉션 또는 ItemsMenu 개체 컬렉션을 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>

설명

이 생성자를 사용하여 메뉴 텍스트, 값, 이미지 URL 및 , MenuItemtextvalue 매개 변수로 지정된 탐색 URL을 사용하여 클래스의 imageUrlnavigateUrl새 인스턴스를 만듭니다.

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

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

이 생성자는 컨트롤의 컬렉션 또는 ItemsMenu 개체 컬렉션을 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>

설명

이 생성자를 사용하여 메뉴 텍스트, 값, 이미지 URL, 탐색 URL 및 각각 , MenuItem, textvalueimageUrl 매개 변수로 지정된 대상을 사용하여 클래스의 navigateUrltarget새 인스턴스를 만듭니다.

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

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

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

추가 정보

적용 대상