ImageButton.CommandName 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컨트롤과 ImageButton 연결된 명령 이름을 가져오거나 설정합니다.
public:
property System::String ^ CommandName { System::String ^ get(); void set(System::String ^ value); };
public string CommandName { get; set; }
[System.Web.UI.Themeable(false)]
public string CommandName { get; set; }
member this.CommandName : string with get, set
[<System.Web.UI.Themeable(false)>]
member this.CommandName : string with get, set
Public Property CommandName As String
속성 값
컨트롤과 연결된 명령 이름입니다 ImageButton . 기본값은 Empty입니다.
구현
- 특성
예제
다음 예제에서는 컨트롤과 CommandName 명령 이름을 연결 하는 속성을 사용 하는 방법을 보여 줍니다 ImageButton .
메모
다음 코드 샘플에서는 단일 파일 코드 모델을 사용하며 코드 숨김 파일에 직접 복사한 경우 제대로 작동하지 않을 수 있습니다. 이 코드 샘플은 .aspx 확장이 있는 빈 텍스트 파일로 복사해야 합니다. Web Forms 코드 모델에 대한 자세한 내용은 ASP.NET Web Forms 페이지 코드 모델을 참조하세요.
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ImageButton CommandName Sample</title>
<script language="C#" runat="server">
void ImageButton_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Sort")
Label1.Text = "You clicked the Sort Button";
else
Label1.Text = "You clicked the Edit Button";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>ImageButton CommandName Sample</h3>
Click an image.<br /><br />
<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort"
ImageUrl="images/pict1.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"/>
<asp:ImageButton id="imagebutton2" runat="server"
AlternateText="Edit"
ImageUrl="images/pict2.jpg"
OnCommand="ImageButton_Command"
CommandName="Edit"/>
<br /><br />
<asp:label id="Label1" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ImageButton CommandName Sample</title>
<script language="VB" runat="server">
Sub ImageButton_Command(sender As Object, e As CommandEventArgs)
If e.CommandName = "Sort" Then
Label1.Text = "You clicked the Sort Button"
Else
Label1.Text = "You clicked the Edit Button"
End If
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>ImageButton CommandName Sample</h3>
Click an image.<br /><br />
<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort"
ImageUrl="images/pict1.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"/>
<asp:ImageButton id="imagebutton2" runat="server"
AlternateText="Edit"
ImageUrl="images/pict2.jpg"
OnCommand="ImageButton_Command"
CommandName="Edit"/>
<br /><br />
<asp:label id="Label1" runat="server"/>
</form>
</body>
</html>
설명
컨트롤을 클릭할 때 ImageButton 수행할 명령을 지정 하려면이 속성을 사용 합니다( 예: Sort, Cancel또는 Edit. 이렇게 하면 동일한 웹 페이지에 여러 ImageButton 컨트롤을 배치할 수 있습니다. 그런 다음, 이 속성의 값을 이벤트 처리기에서 OnCommand 프로그래밍 방식으로 식별하여 각 ImageButton 컨트롤을 클릭할 때 수행할 적절한 작업을 결정할 수 있습니다.
오름차순 정렬 순서 지정과 같은 명령에 대한 추가 정보는 속성을 사용하여 CommandArgument 포함할 수 있습니다.
이 속성은 테마 또는 스타일시트 테마로 설정할 수 없습니다. 자세한 내용은 테마 및 스킨을 참조ThemeableAttribute하고 ASP.NET.