AttributeCollection.CssStyle-Eigenschaft
Ruft eine Auflistung von Formaten für das ASP.NET-Serversteuerelement ab, zu dem das aktuelle AttributeCollection-Objekt gehört.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public ReadOnly Property CssStyle As CssStyleCollection
'Usage
Dim instance As AttributeCollection
Dim value As CssStyleCollection
value = instance.CssStyle
public CssStyleCollection CssStyle { get; }
public:
property CssStyleCollection^ CssStyle {
CssStyleCollection^ get ();
}
/** @property */
public CssStyleCollection get_CssStyle ()
public function get CssStyle () : CssStyleCollection
Eigenschaftenwert
Ein CssStyleCollection-Objekt, das die Formate für das aktuelle Serversteuerelement enthält.
Hinweise
Jedes für ein bestimmtes HTML-Serversteuerelement deklarierte Format wird dem CssStyleCollection-Objekt bei der Analyse der entsprechenden Web Forms-Seite hinzugefügt. Mit dieser Eigenschaft können Sie Formate hinzufügen und entfernen sowie die für das Serversteuerelement deklarierten Formate durchlaufen.
Beispiel
Im folgenden Beispiel wird veranschaulicht, wie ein CSS-Stilwert programmgesteuert der AttributeCollection eines Serversteuerelements hinzugefügt wird. Wenn Sie auf eine Schaltfläche klicken, wird die Hintergrundfarbe eines TextBox-Serversteuerelements, TextBox1
, auf das ausgewählte Element in einem DropDownList-Serversteuerelement, DropDownList1
, festgelegt.
Private Sub Button2_Click(sender As Object, e As System.EventArgs)
Dim myColor As String
Dim myAttributes As AttributeCollection = TextBox1.Attributes
myColor = DropDownList1.Items(DropDownList1.SelectedIndex).Text
' Add the attribute "background-color" in to the CssStyle.
myAttributes.CssStyle.Add("background-color", myColor)
End Sub
private void Button2_Click(object sender, System.EventArgs e)
{
string myColor;
AttributeCollection myAttributes = TextBox1.Attributes;
myColor = DropDownList1.Items[DropDownList1.SelectedIndex].Text;
// Add the attribute "background-color" in to the CssStyle.
myAttributes.CssStyle.Add("background-color",myColor);
}
private void Button2_Click(Object sender, System.EventArgs e)
{
String myColor;
System.Web.UI.AttributeCollection myAttributes = TextBox1.get_Attributes();
myColor = DropDownList1.get_Items().get_Item(DropDownList1.
get_SelectedIndex()).get_Text();
// Add the attribute "background-color" in to the CssStyle.
myAttributes.get_CssStyle().Add("background-color",myColor);
} //Button2_Click
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
AttributeCollection-Klasse
AttributeCollection-Member
System.Web.UI-Namespace
CssStyleCollection