| |||||||
WebControl.CssClass PropertySystem.Web.UI.WebControls Namespace WebControl Class Sets or retrieves the Cascading Style Sheet ( CSS ) class applied to a Web control. Syntax
Property Value
This property is read/write with no default value. RemarksCssClass is used to associate a particular CSS style rule with a Web server control. The style rule may be defined in either an embedded or linked stylesheet. The below snippet shows a sample declaration of an embedded stylesheet, with three CSS class definitions named cool, soso, and warm. <style type = "text/css">
<!--
#greeting {padding:10}
.cool {background:navy; color:lime}
.soso {background:gainsboro; color:dimgray}
.warm {background:maroon; color:gold}
-->
</style>
ExampleThe following example shows how to declaratively set the CssClass property of a Web control at design time, using one of the classes defined in the sample stylesheet above. <asp:textbox id = "myTextBox" cssclass = "cool" runat = "server" /> The example below shows how to programmatically set the CssClass property at run time, depending on user input. Essentially, here's how the code works:
<p>Choose your style: <select id = "myStyle" runat = "server"> <option value = "cool">Cool</option> <option value = "soso">So-So</option> <option value = "warm">Warm</option> </select> <input type=submit Value = "Apply" runat = "server" onServerClick = "chgClass"> void chgClass ( Object src, EventArgs e ) {
// get the selected style and apply
greeting.CssClass = myStyle.Value;
}
See AlsoWebControl Members 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