HtmlTextWriter.IsStyleAttributeDefined Méthode

Définition

Détermine si l'attribut de style de balisage spécifié est rendu au cours de l'appel suivant à la méthode RenderBeginTag.

Surcharges

IsStyleAttributeDefined(HtmlTextWriterStyle)

Détermine si l'attribut de style de balisage spécifié est rendu au cours de l'appel suivant à la méthode RenderBeginTag.

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Détermine si l'attribut de style de balisage spécifié et sa valeur sont rendus au cours de l'appel suivant à la méthode RenderBeginTag.

IsStyleAttributeDefined(HtmlTextWriterStyle)

Détermine si l'attribut de style de balisage spécifié est rendu au cours de l'appel suivant à la méthode RenderBeginTag.

protected:
 bool IsStyleAttributeDefined(System::Web::UI::HtmlTextWriterStyle key);
protected bool IsStyleAttributeDefined (System.Web.UI.HtmlTextWriterStyle key);
member this.IsStyleAttributeDefined : System.Web.UI.HtmlTextWriterStyle -> bool
Protected Function IsStyleAttributeDefined (key As HtmlTextWriterStyle) As Boolean

Paramètres

key
HtmlTextWriterStyle

HtmlTextWriterStyle associé à l'attribut.

Retours

Boolean

true si l'attribut est rendu au cours de l'appel suivant à la méthode RenderBeginTag ; sinon, false.

Exemples

L’exemple de code suivant montre comment vérifier si un <label> élément est affiché. Si c’est le cas, la IsStyleAttributeDefined méthode vérifie si un Color attribut de style a été défini sur l’élément. Si l’attribut Color n’a pas été défini, la AddStyleAttribute méthode définit l’attribut Color et définit sa valeur redsur .

// If the markup element being rendered is a Label,
// render the opening tag of a <Font> element before it.
if ( tagKey == HtmlTextWriterTag::Label )
{
   
   // Check whether a Color style attribute is
   // included on the Label. If not, use the
   // AddStyleAttribute and GetStyleName methods to add one
   // and set its value to red.
   if (  !IsStyleAttributeDefined( HtmlTextWriterStyle::Color ) )
   {
      AddStyleAttribute( GetStyleName( HtmlTextWriterStyle::Color ), "red" );
   }
// If the markup element being rendered is a Label,
// render the opening tag of a Font element before it.
if (tagKey == HtmlTextWriterTag.Label)
{
    // Check whether a Color style attribute is 
    // included on the Label. If not, use the
    // AddStyleAttribute and GetStyleName methods to add one
    // and set its value to red.
    if (!IsStyleAttributeDefined(HtmlTextWriterStyle.Color))
    {
        AddStyleAttribute(GetStyleName(HtmlTextWriterStyle.Color), "red");
    }
' If the markup element being rendered is a Label,
' render the opening tag of a Font element before it.
If tagKey = HtmlTextWriterTag.Label Then
    ' Check whether a Color style attribute is 
    ' included on the Label. If not, use the
    ' AddStyleAttribute and GetStyleName methods to add one
    ' and set its value to red.
    If Not IsStyleAttributeDefined(HtmlTextWriterStyle.Color) Then
        AddStyleAttribute(GetStyleName(HtmlTextWriterStyle.Color), "red")
    End If

Remarques

Pour obtenir la valeur qui sera rendue avec l’attribut de style spécifié, utilisez la IsStyleAttributeDefined(HtmlTextWriterStyle, String) surcharge de la IsStyleAttributeDefined méthode.

Voir aussi

S’applique à

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Détermine si l'attribut de style de balisage spécifié et sa valeur sont rendus au cours de l'appel suivant à la méthode RenderBeginTag.

protected:
 bool IsStyleAttributeDefined(System::Web::UI::HtmlTextWriterStyle key, [Runtime::InteropServices::Out] System::String ^ % value);
protected bool IsStyleAttributeDefined (System.Web.UI.HtmlTextWriterStyle key, out string value);
member this.IsStyleAttributeDefined : System.Web.UI.HtmlTextWriterStyle * string -> bool
Protected Function IsStyleAttributeDefined (key As HtmlTextWriterStyle, ByRef value As String) As Boolean

Paramètres

key
HtmlTextWriterStyle

HtmlTextWriterStyle associé à l'attribut.

value
String

Valeur assignée à l'attribut de style.

Retours

Boolean

true si l'attribut et sa valeur sont rendus au cours de l'appel suivant à la méthode RenderBeginTag ; sinon, false.

Remarques

Si la IsStyleAttributeDefined méthode retourne true, la valeur à affecter à l’attribut HtmlTextWriterStyle est retournée dans le value paramètre.

Voir aussi

S’applique à