Implement a multi-interface (similar to this blog) by enabling pages to dynamically load different CSS
Method One:
<% @page language= "C #"%>
<% @import namespace= "System.Data"%>
C #
Change the interface by dynamically setting the style of all the same controls on the page:
Method Two:
You can easily set and modify the style of a control by changing the CssClass property of the Web control.
However, in the actual development process, set the control of the CssClass property, very cumbersome, so this idea is not widely used.
But the following code snippet shows a way to change the style of all the same controls on a page at once, with simple skin features.
The code is as follows:
public void Page_Load (Object Obj,eventargs E)
{
if (! Page.IsPostBack) {
Sets 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];
Get the type of the control
Can add control types and corresponding processing methods
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>
After running, view the page source code. You can find that the style of the text box has been uniformly modified to "textbox_show".