Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
 LiteralMode, énumération
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
LiteralMode Enumeration

Specifies how the content in a Literal control is rendered.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic
Public Enumeration LiteralMode
C#
public enum LiteralMode
Visual C++
public enum class LiteralMode
F#
type LiteralMode
Member nameDescription
TransformThe literal control's unsupported markup-language elements are removed. If the literal control is rendered on a browser that supports HTML or XHTML, the control's contents are not modified.
PassThroughThe literal control's contents are not modified.
EncodeThe literal control's contents are HTML-encoded.

The LiteralMode enumeration represents the modes that you can specify for how the content in a Literal control is rendered. The Mode property uses these enumeration values to set the behavior of the contents of the Text property in a Literal control.

If you specify PassThrough, the entire contents of the Text property are passed to the device or browser without any modifications. For example, if the Text property of a Literal control contains an <hr> tag, it is sent to all devices and browsers regardless of whether it is supported.

If you specify Encode, the contents for the Text property are converted into an HTML-encoded string before rendering. For example, if the Text property of a Literal control contains an <hr> tag, it will be converted to &lt;hr&gt; and sent to the device or browser.

If you specify Transform, the rendering behavior of the Text property depends on the type of markup being rendered. When the Literal control is rendered for a device or browser that supports HTML or XHTML, specifying Transform produces the same behavior as specifying PassThrough. All markup tags and elements for the Text property are rendered for the requesting browser.

When the Literal control is rendered for a markup language other than HTML or XHTML, such as WML or cHTML, you can use the Transform value to remove unsupported markup elements. In this case, any markup-language elements of the Text property that are not supported in the targeted markup language are not rendered for the control. For example, if the Text property of a Literal control contains an <hr> tag, the tag is removed before the content is sent to a WML device. If an unsupported tag contains content, only the tag is removed and the content is sent to the device or browser. For example, if the Text property contains the content <XYZ>Test</XYZ>, the <XYZ> and </XYZ> tags are removed while the text Test is sent to the device or browser.

The following code example demonstrates how to set a Literal control's Mode property. The Mode property is initially set to Encode in the declarative syntax for the control. After the page loads, the user can click a button to set the Mode property to PassThrough. This causes the contents of the Text property to render differently.

Visual Basic
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
<head>
    <title>Literal.Mode Property Example</title>
<script runat="Server">

        Sub PassThroughButton_Click(ByVal sender As Object, ByVal e As EventArgs)

            Literal1.Mode = LiteralMode.PassThrough

            Label1.Text = "The contents of the Literal.Text property " + _
                          "passed through to the browser:"

        End Sub

   </script>
</head>
<body>
    <form id="Form1" runat="server">

        <h3>Literal.Mode Property Example</h3>        

        <asp:Label ID="Label1"
            Text="The HTML-encoded contents of the Literal.Text property:"
            runat="server">     
        </asp:Label><br /><br />

        <asp:Literal ID="Literal1"
            Mode="Encode"
            Text= "<b>bold</b><br/><i>italic</i><br/>"          
            runat="server">
        </asp:Literal>

        <hr />

        <asp:Button ID="PassThroughButton"
            Text="Pass Through Mode"
            OnClick="PassThroughButton_Click"
            runat="server">
        </asp:Button>

    </form>
</body>
</html>

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Bibliothèque de classes .NET Framework
LiteralMode, énumération

Indique comment le contenu d'un contrôle Literal est restitué.

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web (dans System.Web.dll)
Visual Basic
Public Enumeration LiteralMode
C#
public enum LiteralMode
VisualC++
public enum class LiteralMode
F#
type LiteralMode
Nom de membreDescription
TransformLes éléments de langage de balise non pris en charge pour le contrôle littéral sont supprimés. Si le contrôle littéral est restitué sur un navigateur qui prend en charge HTML ou XHTML, son contenu n'est pas modifié.
PassThroughLe contenu du contrôle littéral n'est pas modifié.
EncodeLe contenu du contrôle littéral est encodé au format HTML.

L'énumération LiteralMode représente les modes de restitution du contenu d'un contrôle Literal. La propriété Mode utilise ces valeurs d'énumération pour définir le comportement du contenu de la propriété Text dans un contrôle Literal.

Si vous spécifiez PassThrough, tout le contenu de la propriété Text est passé à l'appareil ou au navigateur sans aucune modification. Par exemple, si la propriété Text d'un contrôle Literal contient une balise <hr>, elle est envoyée à tous les appareils et navigateurs, qu'elle soit prise en charge ou non.

Si vous spécifiez Encode, le contenu de la propriété Text est converti en une chaîne encodée au format HTML avant d'être restitué. Par exemple, si la propriété Text d'un contrôle Literal contient une balise <hr>, elle est convertie en &lt;hr&gt; puis envoyée à l'appareil ou au navigateur.

Si vous spécifiez Transform, le comportement du rendu de la propriété Text dépend du type de balise restitué. Lorsque le contrôle Literal est rendu pour un appareil ou un navigateur qui prend en charge HTML ou XHTML, la spécification de Transform provoque le même comportement que la spécification de PassThrough. Tous les éléments et instructions de balisage de la propriété Text sont rendus pour le navigateur qui effectue la demande.

Lorsque le contrôle Literal est restitué pour un langage de balisage autre que HTML ou XHTML, par exemple WML ou cHTML, vous pouvez utiliser la valeur Transform pour supprimer les éléments de balisage non pris en charge. Dans ce cas, tous les éléments de langage de balise de la propriété Text qui ne sont pas pris en charge dans le langage de balisage ciblé ne sont pas restitués pour le contrôle. Par exemple, si la propriété Text d'un contrôle Literal contient une balise <hr>, la balise est supprimée avant que le contenu ne soit envoyé à un appareil WML. Si une balise non prise en charge contient des éléments, seule la balise est supprimée et le contenu est envoyé à l'appareil ou au navigateur. Par exemple, si la propriété Text contient le contenu <XYZ>Test</XYZ>, les balises <XYZ> et </XYZ> sont supprimées tandis que le contenu Test est envoyé à l'appareil ou au navigateur.

L'exemple de code suivant montre comment définir la propriété Mode d'un contrôle Literal. La valeur Encode est initialement affectée à la propriété Mode de la syntaxe déclarative du contrôle. Après le chargement de la page, l'utilisateur peut cliquer sur un bouton pour affecter la valeur PassThrough à la propriété Mode. Ainsi, le contenu de la propriété Text est rendu différemment.

Visual Basic
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
<head>
    <title>Literal.Mode Property Example</title>
<script runat="Server">

        Sub PassThroughButton_Click(ByVal sender As Object, ByVal e As EventArgs)

            Literal1.Mode = LiteralMode.PassThrough

            Label1.Text = "The contents of the Literal.Text property " + _
                          "passed through to the browser:"

        End Sub

   </script>
</head>
<body>
    <form id="Form1" runat="server">

        <h3>Literal.Mode Property Example</h3>        

        <asp:Label ID="Label1"
            Text="The HTML-encoded contents of the Literal.Text property:"
            runat="server">     
        </asp:Label><br /><br />

        <asp:Literal ID="Literal1"
            Mode="Encode"
            Text= "<b>bold</b><br/><i>italic</i><br/>"          
            runat="server">
        </asp:Literal>

        <hr />

        <asp:Button ID="PassThroughButton"
            Text="Pass Through Mode"
            OnClick="PassThroughButton_Click"
            runat="server">
        </asp:Button>

    </form>
</body>
</html>

.NET Framework

Pris en charge dans : 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker