Command.ItemCommand 이벤트

정의

사용자가 ObjectList 항목에 연결된 명령을 선택하면 이 이벤트가 발생합니다. 이 API는 더 이상 사용되지 않습니다. ASP.NET 모바일 애플리케이션을 개발하는 방법에 대한 자세한 내용은 ASP.NET 있는 Mobile Apps & 사이트를 참조하세요.

public:
 event System::Web::UI::WebControls::CommandEventHandler ^ ItemCommand;
public event System.Web.UI.WebControls.CommandEventHandler ItemCommand;
member this.ItemCommand : System.Web.UI.WebControls.CommandEventHandler 
Public Custom Event ItemCommand As CommandEventHandler 

이벤트 유형

예제

다음 코드 예제를 사용 ItemCommand 하는 방법에 설명 합니다 페이지에서 여러 명령에 대 한 이벤트입니다.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    void cmd_OnItemCommand(object sender, CommandEventArgs e)
    {
        // Create variables for data
        string txt1 = "Today's quote of {0} is {1}";
        string txt2 = "Yesterday's quote of {0} was {1}";
        int val = (Convert.ToInt32(e.CommandArgument) - 5);
        
        // Set the text values of the labels
        message1.Text = String.Format(txt1, e.CommandName, 
            e.CommandArgument);
        message2.Text = String.Format(txt2, e.CommandName, val);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <p>
            <mobile:label id="message1" runat="server">
                Click the button for quotes
            </mobile:label>
            <mobile:label id="message2" runat="server" />
        </p>
        <mobile:command id="CmdA" Format="Link" 
            onItemCommand ="cmd_OnItemCommand" 
            CommandArgument="70" CommandName="ca" 
            runat="server" Text="Company A" />
        <mobile:command id="CmdB" Format="Link" 
            onItemCommand ="cmd_OnItemCommand" 
            CommandArgument="25" CommandName="cb" 
            runat="server" Text="Company B" />
        <mobile:command id="CmdC" Format="Button" 
            OnItemCommand ="cmd_OnItemCommand" 
            CommandArgument="110" CommandName="cc" 
            runat="server" Text= "Company C" />
    </mobile:form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    Private Sub cmd_OnItemCommand(ByVal sender As Object, ByVal e As CommandEventArgs)
        ' Create variables for data
        Dim txt1 As String = "Today's quote of {0} is {1}"
        Dim txt2 As String = "Yesterday's quote of {0} was {1}"
        Dim Val As Integer = (Convert.ToInt32(e.CommandArgument) - 5)
        
        ' Set the text values of the labels
        message1.Text = String.Format(txt1, e.CommandName, _
            e.CommandArgument)
        message2.Text = String.Format(txt2, e.CommandName, Val)
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <p>
            <mobile:label id="message1" runat="server">
                Click the button for quotes
            </mobile:label>
            <mobile:label id="message2" runat="server" />
        </p>
        <mobile:command id="CmdA" Format="Link" 
            onItemCommand="cmd_OnItemCommand"
            CommandArgument="70" CommandName="ca" 
            runat="server" Text="Company A" />
        <mobile:command id="CmdB" Format="Link"
            onItemCommand ="cmd_OnItemCommand" 
            CommandArgument="25" CommandName="cb" 
            runat="server" Text="Company B" />
        <mobile:command id="CmdC" Format="Button" 
            OnItemCommand="cmd_OnItemCommand"
            CommandArgument="110" CommandName="cc" 
            runat="server" Text="Company C" />
    </mobile:form>
</body>
</html>

설명

ItemCommand 이벤트 처리기가 정의되면 컨트롤은 Command 사용자 상호 작용을 통해 항목 이벤트가 생성될 때 처리기에 알립니다.

이벤트와 Click 달리 ItemCommand 이벤트는 부모 컨트롤에 버블링됩니다. 합니다 ItemCommand 이벤트 렌더링 디바이스별 이며의 "디바이스 관련 동작" 섹션에서 자세히 설명 되어 System.Web.UI.MobileControls.Command입니다.

이벤트는 OnItemCommand 이벤트 후에 발생합니다 OnClick . 명령 단추를 클릭할 때마다 동일한 작업 집합을 반복하는 시나리오에서는 컨트롤의 Command 또는 CommandArgument 속성을 사용하여 CommandName 사용자가 클릭한 명령 단추를 식별할 수 있습니다.

적용 대상

추가 정보