HtmlTextWriter.IsStyleAttributeDefined Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Determina se um atributo de estilo de marcação é renderizado durante a próxima chamada ao RenderBeginTag método.
Sobrecargas
| Name | Description |
|---|---|
| IsStyleAttributeDefined(HtmlTextWriterStyle) |
Determina se o atributo de estilo de marcação especificado é renderizado durante a próxima chamada ao RenderBeginTag método. |
| IsStyleAttributeDefined(HtmlTextWriterStyle, String) |
Determina se o atributo de estilo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método. |
IsStyleAttributeDefined(HtmlTextWriterStyle)
Determina se o atributo de estilo de marcação especificado é renderizado durante a próxima chamada ao RenderBeginTag método.
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
O HtmlTextWriterStyle associado ao atributo.
Devoluções
true se o atributo for renderizado durante a próxima chamada ao RenderBeginTag método; caso contrário, false.
Exemplos
O exemplo de código seguinte mostra como verificar se um <label> elemento está a ser renderizado. Se sim, o IsStyleAttributeDefined método verifica se um Color atributo de estilo foi definido no elemento. Se o Color atributo não tiver sido definido, o AddStyleAttribute método define o Color atributo e define o seu valor para 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
Observações
Para obter o valor que será renderizado com o atributo de estilo especificado, use a IsStyleAttributeDefined(HtmlTextWriterStyle, String) sobrecarga do IsStyleAttributeDefined método.
Ver também
Aplica-se a
IsStyleAttributeDefined(HtmlTextWriterStyle, String)
Determina se o atributo de estilo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método.
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
O HtmlTextWriterStyle associado ao atributo.
- value
- String
O valor atribuído ao atributo de estilo.
Devoluções
true se o atributo e o seu valor forem renderizados durante a próxima chamada ao RenderBeginTag método; caso contrário, false.
Observações
Se o IsStyleAttributeDefined método devolver true, o valor a atribuir ao HtmlTextWriterStyle atributo é devolvido no value parâmetro.