Apply a style in the ASP.NET web control (Style)
Translation: T.T (TPOI)
In this article, I will tell you how to create and apply the style for web server controls using the Web Class in the .NET Framework class library.
System.Web.ui.WebControls.Style class Style class defines the style space of System.Web.ui.WebControls, used to describe a web server control style. The properties of this class can set the look of the web server control, or multiple The web server control uses a universal look. You can change the background color, foreground, border width, border style, and web server control size. Table 1 Attributes of the Style class
Backcolor Gets or sets the background color bordercolor for Web Server Controls Get or sets Border Colors for Web Server Controls Border Color BorderWidth Gets Border Style BorderWidth for Web Server Controls Get or sets the Border Width CssClass to Gets the web server control to get or set up by the web server control in the customer The CSS class font-rendered CSS Font Gets Font Properties with the Web Server Control For Forecolor Get or sets the foreground color of the web server control (usually the text color) Height gets or sets the height of the web server control to get the width of the web server control.
System.Web.ui.WebControls.WebControl.ApplyStyle method ApplyStyle method is to apply the style you set to a web server control. There is a small code below: WebControl ctrl; style s; // Set the properties of Style ... ... // Apply Style Ctrl.ApplyStyle (s); example now I will use an example to explain how to apply the style in the web server control. Create a web application in Visual Studio.net, add 3 controls to the Form, Button, TextBox, ListBox. Add some items to ListBox (using the collecty attribute). Tour to create 2 new methods, createstyle and setControlStyle. CreateStyle and setControlStyle. CreateStyle method has 7 parameters, a background color, foreground color, etc. Value. This method returns a Style object / / this method creates a new style