HtmlTextWriter.TagKey Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera lub ustawia HtmlTextWriterTag wartość określonego elementu znaczników.
protected:
property System::Web::UI::HtmlTextWriterTag TagKey { System::Web::UI::HtmlTextWriterTag get(); void set(System::Web::UI::HtmlTextWriterTag value); };
protected System.Web.UI.HtmlTextWriterTag TagKey { get; set; }
member this.TagKey : System.Web.UI.HtmlTextWriterTag with get, set
Protected Property TagKey As HtmlTextWriterTag
Wartość właściwości
Element znaczników, który ma renderowany tag otwierający.
Wyjątki
Nie można ustawić wartości właściwości.
Przykłady
W poniższym przykładzie kodu pokazano przesłoniętą wersję RenderBeforeContent metody w klasie, która pochodzi z HtmlTextWriter klasy . Używa wartości TagKey właściwości, aby określić, czy kontrolka serwera przy użyciu obiektu niestandardowego HtmlTextWriter renderuje <label> element znaczników. Jeśli tak jest, <font> element z atrybutem color ustawionym na red jest zwracany w celu zmodyfikowania formatowania <label> tekstu elementu.
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
virtual String^ RenderBeforeContent() override
{
// Check to determine whether the element being rendered
// is a label element. If so, render the opening tag
// of the font element; otherwise, call the base method.
if ( TagKey == HtmlTextWriterTag::Label )
{
return "<font color=\"red\">";
}
else
{
return __super::RenderBeforeContent();
}
}
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
protected override string RenderBeforeContent()
{
// Check to determine whether the element being rendered
// is a label element. If so, render the opening tag
// of the font element; otherwise, call the base method.
if (TagKey == HtmlTextWriterTag.Label)
{
return "<font color=\"red\">";
}
else
{
return base.RenderBeforeContent();
}
}
' Override the RenderBeforeContent method to write
' a font element that applies red to the text in a Label element.
Protected Overrides Function RenderBeforeContent() As String
' Check to determine whether the element being rendered
' is a label element. If so, render the opening tag
' of the font element; otherwise, call the base method.
If TagKey = HtmlTextWriterTag.Label Then
Return "<font color=""red"">"
Else
Return MyBase.RenderBeforeContent()
End If
End Function 'RenderBeforeContent
Uwagi
Właściwość TagKey jest używana tylko do klas dziedzicujących po HtmlTextWriter klasie. Należy odczytać lub ustawić TagKey właściwość tylko w wywołaniu RenderBeginTag metody. Jest to jedyny czas, w którym jest ustawiona wartość spójna.