ASP. net Switch CSS implementation of multi-style PAGE method 1 <% @ page Language = "C #" %> <% @ import namespace = "system. data "%> <script language =" C # "runat =" server "> Public void page_load (Object OBJ, eventargs e) {// create a server control. // The specified tag "Link" initializes a new instance of this type. htmlgenericcontrol objlink = new htmlgenericcontrol ("Link"); objlink. id = ID; objlink. attributes ["rel"] = "stylesheet"; objlink. attributes ["type"] = "text/CSS"; objlink. attributes ["href"] = "portal.css ";// This control does not generate any visible output. It is only used as a container for other controls. You can add, insert, or remove controls in it. mycss. controls. add (objlink) ;}</SCRIPT> <HTML> Code Section demonstrates how to change the style of all controls of the same type on the page at one time, and implement simple functions such as skin. The Code is as follows: Reference segment: Public void page_load (Object OBJ, eventargs e) {If (! Page. ispostback) {// set the style for all controls on the page. setcss (page. controls) ;}} private void setcss (system. web. UI. controlcollection vcontrols) {for (INT I = 0; I <vcontrols. count; I ++) {system. web. UI. control vcontrol = vcontrols [I]; // obtain the control type. // you can increase the control type and the corresponding processing method. String ptype = vcontrol. getType (). name; Switch (ptype) {Case "textbox": textbox_css (textbox) vcontrol); break; Case "button": // button_css (button) vcontrol); break; case "DataGrid": // datagrid_css (DataGrid) vcontrol); break;} If (vcontrol. controls. count> 0) setcss (vcontrol. controls) ;}} private void textbox_css (textbox TB) {TB. cssclass = "textbox_show";} <form runat = "server"> <asp: textbox id = "search1" runat = "server"/> <asp: textbox id = "search2" cssclass = "input" runat = "server"/> </form>