Command.Format Propriedade

Definição

Obtém ou define o estilo de renderização do Command. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com ASP.NET.

public:
 property System::Web::UI::MobileControls::CommandFormat Format { System::Web::UI::MobileControls::CommandFormat get(); void set(System::Web::UI::MobileControls::CommandFormat value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.MobileControls.CommandFormat Format { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Format : System.Web.UI.MobileControls.CommandFormat with get, set
Public Property Format As CommandFormat

Valor da propriedade

Um CommandFormat valor que indica o estilo de renderização para o Command.

Atributos

Exemplos

O exemplo a seguir demonstra como usar a Format propriedade para renderizar o comando como um link ou um botão.

Observação

O exemplo de código a seguir usa o modelo de código de arquivo único e pode não funcionar corretamente se copiado diretamente em um arquivo code-behind. Este exemplo de código deve ser copiado para um arquivo de texto vazio que tenha uma extensão .aspx. Para obter mais informações, consulte ASP.NET Web Forms Modelo de Código de Página.

<%@ 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>

Comentários

Acesse os dois tipos disponíveis por meio da CommandFormat enumeração .

CommandFormat.Button (padrão)
O comando é renderizado como um botão.

CommandFormat.Link
O comando é renderizado como um link.

Observação

A Format propriedade dá suporte ao CommandFormat.Link valor somente em dispositivos que dão suporte a JavaScript, conforme indicado pela HttpCapabilitiesBase.JavaScript propriedade .

Aplica-se a

Confira também