CssStyleCollection.Item[] Özellik

Tanım

HTML sunucusu denetimi için bir CSS değeri alır veya ayarlar.

Aşırı Yüklemeler

Item[String]

HTML sunucusu denetimi için belirtilen CSS değerini alır veya ayarlar.

Item[HtmlTextWriterStyle]

HTML sunucusu denetimi için belirtilen HtmlTextWriterStyle değeri alır veya ayarlar.

Item[String]

HTML sunucusu denetimi için belirtilen CSS değerini alır veya ayarlar.

public:
 property System::String ^ default[System::String ^] { System::String ^ get(System::String ^ key); void set(System::String ^ key, System::String ^ value); };
public string this[string key] { get; set; }
member this.Item(string) : string with get, set
Default Public Property Item(key As String) As String

Parametreler

key
String

CSS özniteliğinin dizini.

Özellik Değeri

String

değeri key.

Örnekler

Aşağıdaki kod örneği, denetiminde Item[] ayarlanan HtmlInputText stilin değerini döndürmek için özelliğini kullanır.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
  {
    MyText.Style.Add(HtmlTextWriterStyle.Width, "200");
    FirstMessage.Text = "The text box font color is: " + 
      MyText.Style["color"] + "<br />" +
      "The text box width is: " + 
      MyText.Style[HtmlTextWriterStyle.Width];
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CssCollection This Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <input id="MyText"
             type="text" 
             value="Type a value here."
             style="font: 14pt Verdana; color: blue;"
             runat="server"/>
      <br />
      <asp:Label id="FirstMessage"
                 runat="server"/>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    MyText.Style.Add(HtmlTextWriterStyle.Width, "200")
    FirstMessage.Text = "The text box font color is: " _
      & MyText.Style("color") & "<br />" _
      & "The text box width is: " & MyText.Style(HtmlTextWriterStyle.Width)

  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CssCollection This Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <input id="MyText"
             type="text" 
             value="Type a value here."
             style="font: 14pt Verdana; color: blue;"
             runat="server"/>
      <br />
      <asp:Label id="FirstMessage"
                 runat="server"/>
    </div>
    </form>
</body>
</html>

Ayrıca bkz.

Şunlara uygulanır

Item[HtmlTextWriterStyle]

HTML sunucusu denetimi için belirtilen HtmlTextWriterStyle değeri alır veya ayarlar.

public:
 property System::String ^ default[System::Web::UI::HtmlTextWriterStyle] { System::String ^ get(System::Web::UI::HtmlTextWriterStyle key); void set(System::Web::UI::HtmlTextWriterStyle key, System::String ^ value); };
public string this[System.Web.UI.HtmlTextWriterStyle key] { get; set; }
member this.Item(System.Web.UI.HtmlTextWriterStyle) : string with get, set
Default Public Property Item(key As HtmlTextWriterStyle) As String

Parametreler

Özellik Değeri

String

Değeri key; aksi takdirde, nullsunucu denetiminin koleksiyonunda değilse key .

Örnekler

Aşağıdaki kod örneği, denetiminde Item[] ayarlanan HtmlInputText stilin değerini döndürmek için özelliğini kullanır.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
  {
    MyText.Style.Add(HtmlTextWriterStyle.Width, "200");
    FirstMessage.Text = "The text box font color is: " + 
      MyText.Style["color"] + "<br />" +
      "The text box width is: " + 
      MyText.Style[HtmlTextWriterStyle.Width];
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CssCollection This Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <input id="MyText"
             type="text" 
             value="Type a value here."
             style="font: 14pt Verdana; color: blue;"
             runat="server"/>
      <br />
      <asp:Label id="FirstMessage"
                 runat="server"/>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    MyText.Style.Add(HtmlTextWriterStyle.Width, "200")
    FirstMessage.Text = "The text box font color is: " _
      & MyText.Style("color") & "<br />" _
      & "The text box width is: " & MyText.Style(HtmlTextWriterStyle.Width)

  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CssCollection This Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <input id="MyText"
             type="text" 
             value="Type a value here."
             style="font: 14pt Verdana; color: blue;"
             runat="server"/>
      <br />
      <asp:Label id="FirstMessage"
                 runat="server"/>
    </div>
    </form>
</body>
</html>

Açıklamalar

özelliğine veya Add giriş olarak bir numaralandırma değeri alan HtmlTextWriterStyle yönteme sahip Item[] bir denetim için koleksiyona CssStyleCollection program aracılığıyla eklenen stil öğeleri, özelliğiyle Count döndürülen stil öğelerinin sayısına dahil edilir ve özelliğiyle Value döndürülen dize değişmez değerine dahil edilir. Bu öznitelikler kesin olarak yazıldı. Sunucu denetimine eklemek istediğiniz basamaklı stil sayfası özniteliği numaralandırmada HtmlTextWriterStyle varsa, bu kesin olarak belirlenmiş yöntemleri kullanın. Eklemek istediğiniz öznitelik numaralandırmada HtmlTextWriterStyle yoksa, özelliğini veya Add yöntemini kullanınItem[].

Eklenmemiş bir HtmlTextWriterStyle denetimin numaralandırma değerine CssStyleCollection erişmeye veya özelliği veya Add yöntemiyle Item[] eklenmiş bir CSS özniteliğine erişmeye çalışmak, özelliğini kullanarak Item[] döndürürnull.

Ayrıca bkz.

Şunlara uygulanır