HtmlTextWriter.IsStyleAttributeDefined Método

Definición

Determina si un atributo de estilo de marcado se representa en la siguiente llamada al método RenderBeginTag.

Sobrecargas

IsStyleAttributeDefined(HtmlTextWriterStyle)

Determina si el atributo de estilo de marcado especificado se representa en la siguiente llamada al método RenderBeginTag.

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Determina si el atributo de estilo de marcado especificado y su valor se han de representar en la siguiente llamada al método RenderBeginTag.

IsStyleAttributeDefined(HtmlTextWriterStyle)

Determina si el atributo de estilo de marcado especificado se representa en la siguiente llamada al método 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

Parámetros

key
HtmlTextWriterStyle

HtmlTextWriterStyle asociado al atributo.

Devoluciones

Boolean

true si el atributo de marcado se representa en la siguiente llamada al método RenderBeginTag; en caso contrario, false.

Ejemplos

En el ejemplo de código siguiente se muestra cómo comprobar si se representa un <label> elemento. Si es así, el IsStyleAttributeDefined método comprueba si se ha definido un Color atributo de estilo en el elemento . Si no se ha definido el Color atributo , el AddStyleAttribute método define el Color atributo y establece su valor en 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

Comentarios

Para obtener el valor que se representará con el atributo de estilo especificado, use la IsStyleAttributeDefined(HtmlTextWriterStyle, String) sobrecarga del IsStyleAttributeDefined método .

Consulte también

Se aplica a

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Determina si el atributo de estilo de marcado especificado y su valor se han de representar en la siguiente llamada al método 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

Parámetros

key
HtmlTextWriterStyle

HtmlTextWriterStyle asociado al atributo.

value
String

Valor asignado al atributo de estilo.

Devoluciones

Boolean

true si el atributo de marcado y su valor se representan en la siguiente llamada al método RenderBeginTag; en caso contrario, false.

Comentarios

Si el IsStyleAttributeDefined método devuelve true, el valor que se va a asignar al HtmlTextWriterStyle atributo se devuelve en el value parámetro .

Consulte también

Se aplica a