HtmlTextWriter.IsStyleAttributeDefined Metoda

Definice

Určuje, zda je atribut stylu značky vykreslen během dalšího volání RenderBeginTag metody.

Přetížení

IsStyleAttributeDefined(HtmlTextWriterStyle)

Určuje, zda se zadaný atribut stylu revizí vykresluje během dalšího RenderBeginTag volání metody.

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Určuje, zda zadaný atribut stylu značky a jeho hodnota jsou vykresleny během dalšího volání RenderBeginTag metody.

IsStyleAttributeDefined(HtmlTextWriterStyle)

Určuje, zda se zadaný atribut stylu revizí vykresluje během dalšího RenderBeginTag volání metody.

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

Parametry

key
HtmlTextWriterStyle

Přidruženo HtmlTextWriterStyle k atributu.

Návraty

Boolean

true pokud se atribut vykreslí během dalšího volání RenderBeginTag metody; v opačném případě false.

Příklady

Následující příklad kódu ukazuje, jak zkontrolovat, jestli <label> se vykresluje prvek. Pokud ano, metoda zkontroluje, IsStyleAttributeDefined zda Color byl u elementu definován atribut stylu. Color Pokud atribut nebyl definován, AddStyleAttribute metoda definuje Color atribut a nastaví jeho hodnotu na 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)
{
    // 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

Poznámky

Chcete-li získat hodnotu, která bude vykreslena se zadaným atributem stylu, použijte IsStyleAttributeDefined(HtmlTextWriterStyle, String) přetížení IsStyleAttributeDefined metody.

Viz také

Platí pro

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Určuje, zda zadaný atribut stylu značky a jeho hodnota jsou vykresleny během dalšího volání RenderBeginTag metody.

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

Parametry

key
HtmlTextWriterStyle

Přidruženo HtmlTextWriterStyle k atributu.

value
String

Hodnota přiřazená atributu stylu.

Návraty

Boolean

true pokud se atribut a jeho hodnota vykreslí během dalšího volání RenderBeginTag metody; v opačném případě false.

Poznámky

IsStyleAttributeDefined Pokud metoda vrátí true, hodnota, která má být přiřazena atributu HtmlTextWriterStyle je vrácena v parametruvalue.

Viz také

Platí pro