| |||||||
WebControl.Style PropertySystem.Web.UI.WebControls Namespace WebControl Class Sets or retrieves inline style information for the Web control. Syntax
Property Value
Returns a System.Web.UI.CssStyleCollection that represents the HTML style attribute that is rendered within the opening tag of the Web control. This property is read/write with no default value. RemarksStyle is used to set or get the collection of Cascading Style Sheets ( CSS ) attributes that is applied as an HTML style attribute on a Web control at run time. The syntax for the HTML style attribute is determined by the CSS standard.
This property can be applied to almost all controls. ExampleThe following example shows how to declaratively set the Style property of a Web control at design time. <asp:Label runat = "server" style = "font: bold 12pt arial; background-color: khaki"> The example below shows how to programmatically set the Style property at run time, depending on user input. void applyStyle ( Object src, EventArgs e ) {
switch ( myStyle.SelectedIndex ) {
case 0:
greeting.Style [ "font" ] = "bold italic 13pt verdana";
break;
case 1:
greeting.Style [ "color" ] = "maroon";
break;
case 2:
greeting.Style [ "background-color" ] = "khaki";
break;
case 3:
greeting.Style [ "border" ] = "1px silver inset";
break;
}
}
See AlsoWebControl Members System.Web.UI.CssStyleCollection Base Web Control Properties |
| ||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme