HtmlTextWriter.GetStyleName(HtmlTextWriterStyle) Yöntem

Tanım

Belirtilen HtmlTextWriterStyle numaralandırma değeriyle ilişkili işaretleme stili öznitelik adını alır.

protected:
 System::String ^ GetStyleName(System::Web::UI::HtmlTextWriterStyle styleKey);
protected string GetStyleName (System.Web.UI.HtmlTextWriterStyle styleKey);
member this.GetStyleName : System.Web.UI.HtmlTextWriterStyle -> string
Protected Function GetStyleName (styleKey As HtmlTextWriterStyle) As String

Parametreler

styleKey
HtmlTextWriterStyle

HtmlTextWriterStyle için stil öznitelik adını almak için.

Döndürülenler

String

içinde styleKeybelirtilen numaralandırma değeriyle HtmlTextWriterStyle ilişkilendirilmiş stil özniteliği adı.

Örnekler

Aşağıdaki kod örneği, bir <label> öğenin işlenip işlenmediğinin nasıl denetlendiğini gösterir. Öyleyse, öğesinde bir Color stil özniteliği tanımlanıp tanımlanmadığını denetler. Öznitelik tanımlanmamışsa yöntemi AddStyleAttribute çağrılır ve GetStyleName yöntem, yönteme geçirmek için sabit listesi üyesini dize gösterimine AddStyleAttribute dönüştürürColor.

// 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

Açıklamalar

Geçerli HtmlTextWriterStyle bir nesne değilsestyleKey, GetStyleName yöntem boş bir dize ("") döndürür.

Şunlara uygulanır

Ayrıca bkz.