HtmlTextWriter.IsAttributeDefined Metoda

Definicja

Określa, czy określony atrybut znaczników i jego wartość są renderowane podczas następnego wywołania RenderBeginTag metody.

Przeciążenia

IsAttributeDefined(HtmlTextWriterAttribute)

Określa, czy określony atrybut znaczników i jego wartość są renderowane podczas następnego wywołania RenderBeginTag metody.

IsAttributeDefined(HtmlTextWriterAttribute, String)

Określa, czy określony atrybut znaczników i jego wartość są renderowane podczas następnego wywołania RenderBeginTag metody.

IsAttributeDefined(HtmlTextWriterAttribute)

Określa, czy określony atrybut znaczników i jego wartość są renderowane podczas następnego wywołania RenderBeginTag metody.

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

Parametry

key
HtmlTextWriterAttribute

Skojarzony HtmlTextWriterAttribute z atrybutem znaczników.

Zwraca

truejeśli atrybut jest renderowany podczas następnego wywołania RenderBeginTag metody ; w przeciwnym razie . false

Przykłady

W poniższym przykładzie kodu pokazano, jak użyć zastąpienia RenderBeginTag metody w klasie dziedziczonej HtmlTextWriter z klasy. Przesłonięcia RenderBeginTag sprawdza, czy <font> element znaczników zostanie renderowany. Jeśli tak, zastąpienie wywołuje metodę IsAttributeDefined w celu sprawdzenia, czy <font> element zawiera Size atrybut. Jeśli tak nie jest, AddAttribute metoda wywołuje metodę GetAttributeKeySize , która definiuje atrybut i ustawia jej wartość na 30pt.

// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point.
if ( tagKey == HtmlTextWriterTag::Font )
{
   if (  !IsAttributeDefined( HtmlTextWriterAttribute::Size ) )
   {
      AddAttribute( GetAttributeKey( "size" ), "30pt" );
   }
}
// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point. 
if (tagKey == HtmlTextWriterTag.Font)
{
    if (!IsAttributeDefined(HtmlTextWriterAttribute.Size))
    {
        AddAttribute(GetAttributeKey("size"), "30pt");
    }
}
' If the tagKey parameter is set to a <font> element
' but a size attribute is not defined on the element,
' the AddStyleAttribute method adds a size attribute
' and sets it to 30 point. 
If tagKey = HtmlTextWriterTag.Font Then
    If Not IsAttributeDefined(HtmlTextWriterAttribute.Size) Then
        AddAttribute(GetAttributeKey("size"), "30pt")
    End If
End If

Uwagi

Aby uzyskać wartość, która ma zostać przypisana do HtmlTextWriterAttribute obiektu, użyj IsAttributeDefined(HtmlTextWriterAttribute, String) przeciążenia zamiast tego.

Zobacz też

Dotyczy

IsAttributeDefined(HtmlTextWriterAttribute, String)

Określa, czy określony atrybut znaczników i jego wartość są renderowane podczas następnego wywołania RenderBeginTag metody.

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

Parametry

key
HtmlTextWriterAttribute

Skojarzony HtmlTextWriterAttribute z atrybutem znaczników.

value
String

Wartość przypisana do atrybutu.

Zwraca

truejeśli atrybut jest renderowany podczas następnego wywołania RenderBeginTag metody ; w przeciwnym razie . false

Uwagi

IsAttributeDefined Jeśli metoda zwróci truewartość , która ma zostać przypisana do HtmlTextWriterAttribute obiektu, zostanie zwrócona w parametrze value .

Zobacz też

Dotyczy