Style Style Style Style Class

Definition

Stellt den Stil eines Webserversteuerelements dar.Represents the style of a Web server control.

public ref class Style : System::ComponentModel::Component, System::Web::UI::IStateManager
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.EmptyStringExpandableObjectConverter))]
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class Style : System.ComponentModel.Component, System.Web.UI.IStateManager
type Style = class
    inherit Component
    interface IStateManager
Public Class Style
Inherits Component
Implements IStateManager
Vererbung
Abgeleitet
Attribute
Implementiert

Beispiele

In diesem Beispiel wird veranschaulicht, wie Style ein-Objekt verwendet wird, um die Stileigenschaften mehrerer Steuerelemente gleichzeitig zu ändern.This example demonstrates how to use a Style object to change the style properties of multiple controls at once. Jedes Mal, wenn sich Style einer der Eigenschaftswerte ändert, muss jedes ApplyStyle Steuerelement seine-Methode aufruft.Each time one of the Style property values changes, each control must call its ApplyStyle method. Beachten Sie, dass nicht alle-Steuerelemente alle gezeigten Eigenschaften unterstützen.Note that not all the controls included support all the properties demonstrated. Wenn ein Steuerelement eine bestimmte Eigenschaft nicht unterstützt, wird die Darstellung des Steuer Elements nicht geändert, wenn der Eigenschafts Wert geändert wird.If a control does not support a particular property, the appearance of the control will not change when the property value is changed.

Hinweis

Im folgenden Codebeispiel wird das Einzel Datei-Code Modell verwendet und funktioniert möglicherweise nicht ordnungsgemäß, wenn es direkt in eine Code-Behind-Datei kopiert wird.The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. Dieses Codebeispiel muss in eine leere Textdatei mit der Erweiterung ASPX kopiert werden.This code sample must be copied into an empty text file that has an .aspx extension. Weitere Informationen zum Web Forms-Code Modell finden Sie unter ASP.net Web Forms Page Code Model.For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

<!--  -->
<!-- -->
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>

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

<script runat="server">
    private Style primaryStyle = new Style();

    void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Add data to the borderColorList, 
            // backColorList, and foreColorList controls.
            ListItemCollection colors = new ListItemCollection();
            colors.Add(Color.Black.Name);
            colors.Add(Color.Blue.Name);
            colors.Add(Color.Green.Name);
            colors.Add(Color.Orange.Name);
            colors.Add(Color.Purple.Name);
            colors.Add(Color.Red.Name);
            colors.Add(Color.White.Name);
            colors.Add(Color.Yellow.Name);
            borderColorList.DataSource = colors;
            borderColorList.DataBind();
            backColorList.DataSource = colors;
            backColorList.DataBind();
            foreColorList.DataSource = colors;
            foreColorList.DataBind();
            //<Snippet4>              

            // Add data to the borderStyleList control.
            ListItemCollection styles = new ListItemCollection();
            Type styleType = typeof(BorderStyle);
            foreach (string s in Enum.GetNames(styleType))
            {
                styles.Add(s);
            }
            borderStyleList.DataSource = styles;
            borderStyleList.DataBind();
            //</Snippet4>           

            // Add data to the borderWidthList control.
            ListItemCollection widths = new ListItemCollection();
            for (int i = 0; i < 11; i++)
            {
                widths.Add(i.ToString() + "px");
            }
            borderWidthList.DataSource = widths;
            borderWidthList.DataBind();

            // Add data to the fontNameList control.
            ListItemCollection names = new ListItemCollection();
            names.Add("Arial");
            names.Add("Courier");
            names.Add("Garamond");
            names.Add("Times New Roman");
            names.Add("Verdana");
            fontNameList.DataSource = names;
            fontNameList.DataBind();

            // Add data to the fontSizeList control.
            ListItemCollection fontSizes = new ListItemCollection();
            fontSizes.Add("Small");
            fontSizes.Add("Medium");
            fontSizes.Add("Large");
            fontSizes.Add("10pt");
            fontSizes.Add("14pt");
            fontSizes.Add("20pt");
            fontSizeList.DataSource = fontSizes;
            fontSizeList.DataBind();

            //Set primaryStyle as the style for each control.
            Label1.ApplyStyle(primaryStyle);
            ListBox1.ApplyStyle(primaryStyle);
            Button1.ApplyStyle(primaryStyle);
            Table1.ApplyStyle(primaryStyle);
            TextBox1.ApplyStyle(primaryStyle);
        }
    }
    //<Snippet5>
    void ChangeBorderColor(object sender, System.EventArgs e)
    {
        primaryStyle.BorderColor =
            Color.FromName(borderColorList.SelectedItem.Text);
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet5>

    //<Snippet6>
    void ChangeBackColor(object sender, System.EventArgs e)
    {
        primaryStyle.BackColor =
            Color.FromName(backColorList.SelectedItem.Text);
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet6>

    //<Snippet7>
    void ChangeForeColor(object sender, System.EventArgs e)
    {
        primaryStyle.ForeColor =
            Color.FromName(foreColorList.SelectedItem.Text);
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet7>

    //<Snippet8>
    void ChangeBorderStyle(object sender, System.EventArgs e)
    {
        primaryStyle.BorderStyle =
            (BorderStyle)Enum.Parse(typeof(BorderStyle),
            borderStyleList.SelectedItem.Text);
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet8>

    //<Snippet9>
    void ChangeBorderWidth(object sender, System.EventArgs e)
    {
        primaryStyle.BorderWidth =
            Unit.Parse(borderWidthList.SelectedItem.Text);
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet9>

    //<Snippet10>
    void ChangeFont(object sender, System.EventArgs e)
    {
        primaryStyle.Font.Name =
            fontNameList.SelectedItem.Text;
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet10>

    //<Snippet11>
    void ChangeFontSize(object sender, System.EventArgs e)
    {
        primaryStyle.Font.Size =
            FontUnit.Parse(fontSizeList.SelectedItem.Text);
        Label1.ApplyStyle(primaryStyle);
        ListBox1.ApplyStyle(primaryStyle);
        Button1.ApplyStyle(primaryStyle);
        Table1.ApplyStyle(primaryStyle);
        TextBox1.ApplyStyle(primaryStyle);
    }
    //</Snippet11>
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <table cellpadding="6" border="0">
        <tr>
            <td rowspan="10" style="border:solid 1px Gray">
                <p>
                    <asp:label id="Label1" 
                        Text="Border Properties Example" Runat="server">
                        Label Styles
                    </asp:label>
                </p>
                <p>
                    <asp:button id="Button1" runat="server" 
                        Text="Button Styles">
                    </asp:button>
                </p>
                <p>
                    <asp:listbox id="ListBox1" Runat="server">
                        <asp:ListItem Value="0" Text="List Item 0">
                        </asp:ListItem>
                        <asp:ListItem Value="1" Text="List Item 1">
                        </asp:ListItem>
                        <asp:ListItem Value="2" Text="List Item 2">
                        </asp:ListItem>
                    </asp:listbox>
                </p>
                <p>
                    <asp:textbox id="TextBox1" 
                        Text="TextBox Styles" Runat="server">
                    </asp:textbox>
                </p>
                <p>
                    <asp:table id="Table1" Runat="server">
                        <asp:TableRow>
                            <asp:TableCell Text="(0,0)"></asp:TableCell>
                            <asp:TableCell Text="(0,1)"></asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell Text="(1,0)"></asp:TableCell>
                            <asp:TableCell Text="(1,1)"></asp:TableCell>
                        </asp:TableRow>
                    </asp:table>
                </p>
            </td>
            <td align="right">
                <asp:Label ID="Label2" runat="server" 
                    AssociatedControlID="borderColorList" 
                    Text="Border Color:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="borderColorList" 
                    Runat="server" AutoPostBack="True" 
                    OnSelectedIndexChanged="ChangeBorderColor">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label3" Runat="server" 
                    AssociatedControlID="borderStyleList"
                    Text="Border Style:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="borderStyleList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeBorderStyle">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label4" Runat="server" 
                    AssociatedControlID="borderWidthList"
                    Text="Border Width">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="borderWidthList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeBorderWidth">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label5" Runat="server" 
                    AssociatedControlID="backColorList"
                    Text="Back Color:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="backColorList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeBackColor">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label6" Runat="server" 
                    AssociatedControlID="foreColorList"
                    Text="Foreground Color:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="foreColorList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeForeColor">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label7" Runat="server" 
                    AssociatedControlID="fontNameList"
                    Text="Font Name:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="fontNameList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeFont">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label8" Runat="server" 
                    AssociatedControlID="fontSizeList"
                    Text="Font Size:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="fontSizeList" 
                    Runat="server" AutoPostBack="True" 
                    OnSelectedIndexChanged="ChangeFontSize">
                </asp:dropdownlist>
            </td>
        </tr>
    </table>

    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Drawing" %>

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

<script runat="server">
    Private primaryStyle As New Style()

    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not Page.IsPostBack Then
            ' Add data to the borderColorList, 
            ' backColorList, and foreColorList controls.
            Dim colors As New ListItemCollection()
            colors.Add(Color.Black.Name)
            colors.Add(Color.Blue.Name)
            colors.Add(Color.Green.Name)
            colors.Add(Color.Orange.Name)
            colors.Add(Color.Purple.Name)
            colors.Add(Color.Red.Name)
            colors.Add(Color.White.Name)
            colors.Add(Color.Yellow.Name)
            borderColorList.DataSource = colors
            borderColorList.DataBind()
            backColorList.DataSource = colors
            backColorList.DataBind()
            foreColorList.DataSource = colors
            foreColorList.DataBind()
                
            '<Snippet4>
            ' Add data to the borderStyleList control.
            Dim styles As New ListItemCollection()
            Dim styleType As Type = GetType(BorderStyle)
            Dim s As String
            For Each s In [Enum].GetNames(styleType)
                styles.Add(s)
            Next s
            borderStyleList.DataSource = styles
            borderStyleList.DataBind()
            '</Snippet4>           

            ' Add data to the borderWidthList control.
            Dim widths As New ListItemCollection()
            Dim i As Integer
            For i = 0 To 10
                widths.Add(i.ToString() & "px")
            Next i
            borderWidthList.DataSource = widths
            borderWidthList.DataBind()

            ' Add data to the fontNameList control.
            Dim names As New ListItemCollection()
            names.Add("Arial")
            names.Add("Courier")
            names.Add("Garamond")
            names.Add("Times New Roman")
            names.Add("Verdana")
            fontNameList.DataSource = names
            fontNameList.DataBind()

            ' Add data to the fontSizeList control.
            Dim fontSizes As New ListItemCollection()
            fontSizes.Add("Small")
            fontSizes.Add("Medium")
            fontSizes.Add("Large")
            fontSizes.Add("10pt")
            fontSizes.Add("14pt")
            fontSizes.Add("20pt")
            fontSizeList.DataSource = fontSizes
            fontSizeList.DataBind()
                    
            ' Set primaryStyle as the style for each control.
            Label1.ApplyStyle(primaryStyle)
            ListBox1.ApplyStyle(primaryStyle)
            Button1.ApplyStyle(primaryStyle)
            Table1.ApplyStyle(primaryStyle)
            TextBox1.ApplyStyle(primaryStyle)
        End If
    End Sub

    '<Snippet5>
    Sub ChangeBorderColor(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.BorderColor = _
            Color.FromName(borderColorList.SelectedItem.Text)
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet5>

    '<Snippet6>    
    Sub ChangeBackColor(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.BackColor = _
            Color.FromName(backColorList.SelectedItem.Text)
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet6>

    '<Snippet7>
    Sub ChangeForeColor(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.ForeColor = _
            Color.FromName(foreColorList.SelectedItem.Text)
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet7>

    '<Snippet8>
    Sub ChangeBorderStyle(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.BorderStyle = _
            CType([Enum].Parse(GetType(BorderStyle), _
            borderStyleList.SelectedItem.Text), BorderStyle)
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet8>

    '<Snippet9>
    Sub ChangeBorderWidth(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.BorderWidth = _
            Unit.Parse(borderWidthList.SelectedItem.Text)
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet9>

    '<Snippet10>
    Sub ChangeFont(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.Font.Name = _
            fontNameList.SelectedItem.Text
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet10>

    '<Snippet11>
    Sub ChangeFontSize(ByVal sender As Object, ByVal e As System.EventArgs)
        primaryStyle.Font.Size = _
            FontUnit.Parse(fontSizeList.SelectedItem.Text)
        Label1.ApplyStyle(primaryStyle)
        ListBox1.ApplyStyle(primaryStyle)
        Button1.ApplyStyle(primaryStyle)
        Table1.ApplyStyle(primaryStyle)
        TextBox1.ApplyStyle(primaryStyle)
    End Sub
    '</Snippet11>
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Applied Style Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <table cellpadding="6" border="0">
        <tr>
            <td rowspan="10" style="border:solid 1px Gray">
                <p>
                    <asp:label id="Label1" 
                        Text="Border Properties Example" Runat="server">
                        Label Styles
                    </asp:label>
                </p>
                <p>
                    <asp:button id="Button1" runat="server" 
                        Text="Button Styles">
                    </asp:button>
                </p>
                <p>
                    <asp:listbox id="ListBox1" Runat="server">
                        <asp:ListItem Value="0" Text="List Item 0">
                        </asp:ListItem>
                        <asp:ListItem Value="1" Text="List Item 1">
                        </asp:ListItem>
                        <asp:ListItem Value="2" Text="List Item 2">
                        </asp:ListItem>
                    </asp:listbox>
                </p>
                <p>
                    <asp:textbox id="TextBox1" 
                        Text="TextBox Styles" Runat="server">
                    </asp:textbox>
                </p>
                <p>
                    <asp:table id="Table1" Runat="server">
                        <asp:TableRow>
                            <asp:TableCell Text="(0,0)"></asp:TableCell>
                            <asp:TableCell Text="(0,1)"></asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell Text="(1,0)"></asp:TableCell>
                            <asp:TableCell Text="(1,1)"></asp:TableCell>
                        </asp:TableRow>
                    </asp:table>
                </p>
            </td>
            <td align="right">
                <asp:Label ID="Label2" runat="server" 
                    AssociatedControlID="borderColorList" 
                    Text="Border Color:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="borderColorList" 
                    Runat="server" AutoPostBack="True" 
                    OnSelectedIndexChanged="ChangeBorderColor">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label3" Runat="server" 
                    AssociatedControlID="borderStyleList"
                    Text="Border Style:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="borderStyleList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeBorderStyle">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label4" Runat="server" 
                    AssociatedControlID="borderWidthList"
                    Text="Border Width">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="borderWidthList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeBorderWidth">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label5" Runat="server" 
                    AssociatedControlID="backColorList"
                    Text="Back Color:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="backColorList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeBackColor">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label6" Runat="server" 
                    AssociatedControlID="foreColorList"
                    Text="Foreground Color:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="foreColorList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeForeColor">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label7" Runat="server" 
                    AssociatedControlID="fontNameList"
                    Text="Font Name:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="fontNameList" 
                    Runat="server" AutoPostBack="True"
                    OnSelectedIndexChanged="ChangeFont">
                </asp:dropdownlist>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="Label8" Runat="server" 
                    AssociatedControlID="fontSizeList"
                    Text="Font Size:">
                </asp:Label>
            </td>
            <td>
                <asp:dropdownlist id="fontSizeList" 
                    Runat="server" AutoPostBack="True" 
                    OnSelectedIndexChanged="ChangeFontSize">
                </asp:dropdownlist>
            </td>
        </tr>
    </table>

    </div>
    </form>
</body>
</html>

Hinweise

Die Style -Klasse kapselt die Eigenschaften, die die Darstellung eines Webserver Steuer Elements steuern, und kann auf mehrere Webserver-Steuerelemente angewendet werden, um eine gemeinsame Darstellung bereitzustellen.The Style class encapsulates the properties that control the appearance of a Web server control and can be applied to multiple Web server controls to provide a common appearance. Sie können die Hintergrundfarbe und Schriftfarbe eines Steuerelements angeben, durch Festlegen der BackColor und ForeColor Eigenschaften bzw.You can specify the background color and font color of a control by setting the BackColor and ForeColor properties, respectively. Bei Steuerelementen, die einen Rahmen anzeigen können, können Sie die Rahmenbreite, die Rahmenart und die Rahmenfarbe steuern, indem BorderWidthSie BorderStyledie Eigenschaften BorderColor , und festlegen.On controls that can display a border, you can control the border width, the border style, and the border color by setting the BorderWidth, BorderStyle, and BorderColor properties. Die Größe eines Webserver Steuer Elements kann auch mit der Height -Eigenschaft und der- Width Eigenschaft angegeben werden.The size of a Web server control can also be specified by using the Height and Width properties.

Konstruktoren

Style() Style() Style() Style()

Initialisiert eine neue Instanz der Style-Klasse mit Standardwerten.Initializes a new instance of the Style class using default values.

Style(StateBag) Style(StateBag) Style(StateBag) Style(StateBag)

Initialisiert eine neue Instanz der Style-Klasse mit den angegebenen Datenauflistungsinformationen.Initializes a new instance of the Style class with the specified state bag information.

Eigenschaften

BackColor BackColor BackColor BackColor

Ruft die Hintergrundfarbe des Webserversteuerelements ab oder legt diese fest.Gets or sets the background color of the Web server control.

BorderColor BorderColor BorderColor BorderColor

Ruft die Rahmenfarbe des Webserversteuerelements ab oder legt diese fest.Gets or sets the border color of the Web server control.

BorderStyle BorderStyle BorderStyle BorderStyle

Ruft die Rahmenart des Webserversteuerelements ab oder legt diese fest.Gets or sets the border style of the Web server control.

BorderWidth BorderWidth BorderWidth BorderWidth

Ruft die Rahmenbreite des Webserversteuerelements ab oder legt diese fest.Gets or sets the border width of the Web server control.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Ruft einen Wert ab, der angibt, ob die Komponente ein Ereignis auslösen kann.Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

Ruft den IContainer ab, der die Component enthält.Gets the IContainer that contains the Component.

(Inherited from Component)
CssClass CssClass CssClass CssClass

Ruft die vom Webserver-Steuerelement auf dem Client gerenderte CSS-Klasse (Cascading Style Sheet) ab oder legt diese fest.Gets or sets the cascading style sheet (CSS) class rendered by the Web server control on the client.

DesignMode DesignMode DesignMode DesignMode

Ruft einen Wert ab, der angibt, ob sich Component gegenwärtig im Entwurfsmodus befindet.Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

Ruft die Liste der Ereignishandler ab, die dieser Component angefügt sind.Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Font Font Font Font

Ruft die Schriftarteigenschaften ab, die dem Webserversteuerelement zugeordnet sind.Gets the font properties associated with the Web server control.

ForeColor ForeColor ForeColor ForeColor

Ruft die Vordergrundfarbe (i. A. die Textfarbe) für das Webserversteuerelement ab oder legt diese fest.Gets or sets the foreground color (typically the color of the text) of the Web server control.

Height Height Height Height

Ruft die Höhe des Webserversteuerelements ab oder legt diese fest.Gets or sets the height of the Web server control.

IsEmpty IsEmpty IsEmpty IsEmpty

Eine geschützte Eigenschaft.A protected property. Ruft einen Wert ab, der angibt, ob in der Datenauflistung Stilelemente definiert wurden.Gets a value indicating whether any style elements have been defined in the state bag.

IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

Gibt einen Wert zurück, der angibt, ob in der Datenauflistung Stilelemente definiert wurden.Returns a value indicating whether any style elements have been defined in the state bag.

RegisteredCssClass RegisteredCssClass RegisteredCssClass RegisteredCssClass

Ruft die für das Steuerelement registrierte CSS-Klasse (Cascading Style Sheet) ab.Gets the cascading style sheet (CSS) class that is registered with the control.

Site Site Site Site

Ruft den ISite von Component ab oder legt ihn fest.Gets or sets the ISite of the Component.

(Inherited from Component)
ViewState ViewState ViewState ViewState

Ruft die Datenauflistung ab, die die Stilelemente enthält.Gets the state bag that holds the style elements.

Width Width Width Width

Ruft die Breite des Webserver-Steuerelements ab oder legt sie fest.Gets or sets the width of the Web server control.

Methoden

AddAttributesToRender(HtmlTextWriter) AddAttributesToRender(HtmlTextWriter) AddAttributesToRender(HtmlTextWriter) AddAttributesToRender(HtmlTextWriter)

Fügt dem angegebenen HtmlTextWriter die darzustellenden HTML-Attribute und -Stile hinzu.Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriter. Diese Methode wird hauptsächlich von Steuerelemententwicklern verwendet.This method is primarily used by control developers.

AddAttributesToRender(HtmlTextWriter, WebControl) AddAttributesToRender(HtmlTextWriter, WebControl) AddAttributesToRender(HtmlTextWriter, WebControl) AddAttributesToRender(HtmlTextWriter, WebControl)

Fügt dem angegebenen HtmlTextWriter und dem Webserver-Steuerelement die darzustellenden HTML-Attribute und -Stile hinzu.Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriter and Web server control. Diese Methode wird hauptsächlich von Steuerelemententwicklern verwendet.This method is primarily used by control developers.

CopyFrom(Style) CopyFrom(Style) CopyFrom(Style) CopyFrom(Style)

Dupliziert die Stileigenschaften des angegebenen Style in die Instanz der Style-Klasse, aus der diese Methode aufgerufen wird.Duplicates the style properties of the specified Style into the instance of the Style class that this method is called from.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Erstellt ein Objekt mit allen relevanten Informationen, die zum Generieren eines Proxys für die Kommunikation mit einem Remoteobjekt erforderlich sind.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Gibt alle vom Component verwendeten Ressourcen frei.Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Gibt die von Component verwendeten nicht verwalteten Ressourcen und optional die verwalteten Ressourcen frei.Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.Determines whether the specified object is equal to the current object.

(Inherited from Object)
FillStyleAttributes(CssStyleCollection, IUrlResolutionService) FillStyleAttributes(CssStyleCollection, IUrlResolutionService) FillStyleAttributes(CssStyleCollection, IUrlResolutionService) FillStyleAttributes(CssStyleCollection, IUrlResolutionService)

Fügt einem CssStyleCollection-Objekt die Stileigenschaften des angegebenen Objekts hinzu.Adds the specified object's style properties to a CssStyleCollection object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fungiert als Standardhashfunktion.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Ruft das aktuelle Lebensdauerdienstobjekt ab, das die Lebensdauerrichtlinien für diese Instanz steuert.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Gibt ein Objekt zurück, das einen von der Component oder von deren Container bereitgestellten Dienst darstellt.Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetStyleAttributes(IUrlResolutionService) GetStyleAttributes(IUrlResolutionService) GetStyleAttributes(IUrlResolutionService) GetStyleAttributes(IUrlResolutionService)

Ruft das CssStyleCollection-Objekt für das angegebene, von IUrlResolutionService implementierte Objekt ab.Retrieves the CssStyleCollection object for the specified IUrlResolutionService-implemented object.

GetType() GetType() GetType() GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Ruft ein Lebensdauerdienstobjekt zur Steuerung der Lebensdauerrichtlinie für diese Instanz ab.Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
LoadViewState(Object) LoadViewState(Object) LoadViewState(Object) LoadViewState(Object)

Lädt den zuvor gespeicherten Zustand.Loads the previously saved state.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Erstellt eine flache Kopie des aktuellen MarshalByRefObject-Objekts.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
MergeWith(Style) MergeWith(Style) MergeWith(Style) MergeWith(Style)

Kombiniert die Stileigenschaften des angegebenen Style mit der Instanz der Style-Klasse, aus der diese Methode aufgerufen wird.Combines the style properties of the specified Style with the instance of the Style class that this method is called from.

Reset() Reset() Reset() Reset()

Entfernt alle definierten Stilelemente aus der Datenauflistung.Removes any defined style elements from the state bag.

SaveViewState() SaveViewState() SaveViewState() SaveViewState()

Eine geschützte Methode.A protected method. Speichert jeden Zustand, der nach dem Aufruf der TrackViewState()-Methode geändert wurde.Saves any state that has been modified after the TrackViewState() method was invoked.

SetBit(Int32) SetBit(Int32) SetBit(Int32) SetBit(Int32)

Eine geschützte interne Methode.A protected internal method. Legt ein internes Bitmaskenfeld fest, das die in der Datenauflistung gespeicherten Stileigenschaften angibt.Sets an internal bitmask field that indicates the style properties that are stored in the state bag.

SetDirty() SetDirty() SetDirty() SetDirty()

Markiert den Style, damit sein Zustand im Ansichtszustand aufgezeichnet wird.Marks the Style so that its state will be recorded in view state.

ToString() ToString() ToString() ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

TrackViewState() TrackViewState() TrackViewState() TrackViewState()

Eine geschützte Methode.A protected method. Markiert den Beginn der Verfolgung von Zustandsänderungen für das Steuerelement.Marks the beginning for tracking state changes on the control. Alle Änderungen nach Beginn der Nachverfolgung werden nachverfolgt und als Teil des Ansichtszustands des Steuerelements gespeichert.Any changes made after tracking has begun will be tracked and saved as part of the control view state.

Explizite Schnittstellenimplementierungen

IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState

Ruft einen Wert ab, der angibt, ob ein Serversteuerelement Änderungen des Ansichtszustands nachverfolgt.Gets a value that indicates whether a server control is tracking its view state changes.

IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object)

Lädt den zuvor gespeicherten Zustand.Loads the previously saved state.

IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState()

Gibt das Objekt zurück, das Zustandsänderungen enthält.Returns the object containing state changes.

IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState()

Startet das Verfolgen von Zustandsänderungen.Starts tracking state changes.

Ereignisse

Disposed Disposed Disposed Disposed

Tritt ein, wenn die Komponente durch einen Aufruf der Dispose()-Methode freigegeben wird.Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Gilt für:

Siehe auch