Command.Format Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit le style de rendu de Command. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Applications mobiles & Sites avec 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
Valeur de propriété
Valeur CommandFormat qui indique le style de rendu de Command.
- Attributs
Exemples
L’exemple suivant montre comment utiliser la Format propriété pour afficher la commande sous la forme d’un lien ou d’un bouton.
Notes
L’exemple de code suivant utilise le modèle de code à fichier unique et peut ne pas fonctionner correctement s’il est copié directement dans un fichier code-behind. Cet exemple de code doit être copié dans un fichier texte vide qui a une extension .aspx. Pour plus d’informations, consultez ASP.NET Web Forms Modèle de code de page.
<%@ 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>
Remarques
Accédez aux deux types disponibles via l’énumération CommandFormat .
CommandFormat.Button (valeur par défaut)
La commande est affichée sous la forme d’un bouton.
CommandFormat.Link
La commande est rendue sous la forme d’un lien.
Notes
La Format propriété prend en charge la CommandFormat.Link valeur uniquement sur les appareils qui prennent en charge JavaScript comme indiqué par la HttpCapabilitiesBase.JavaScript propriété .
S’applique à
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour