asp.net.ph

WebControl.Style Property

System.Web.UI.WebControls Namespace   WebControl Class


Sets or retrieves inline style information for the Web control.

Syntax


Inline <asp:control Style = strStyle ... >
Script WebControl.Style [ = strStyle ]

Property Value


strStyle String specifying the declaration block syntax for the inline stylesheet.

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.

Remarks

Style 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.

NOTE: For reference, see the Cascading Style Sheets, Level 2 Specification for the complete list, description, and sample usage of style declaration syntax.

This property can be applied to almost all controls.

Example

The 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;
   }
}

 Show me 

See Also

WebControl Members   System.Web.UI.CssStyleCollection   Base Web Control Properties Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 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 asp.net.ph