In this tutorial, we will show you how to use CSS and Theme to define the style of the page in ASP.NET 2.0 and VB.NET
CSS and Theme in ASP.NET 2.0 and VB.NET
In this tutorial, we will show you how to use CSS and Theme to define the style of the page in ASP.NET 2.0 and VB.NET
We will use the namespace of System.Web.UI in this tutorial.
We used over 10 web hosting companies before we found Server Intellect. Their dedicated servers
and add-ons were setup swiftly, in less than 24 hours. We were able to
confirm our order over the phone. They respond to our inquiries within
an hour. Server Intellect's customer support and assistance are the best we've ever experienced.
Please add two controls of
labels, textboxs and buttons to the webpage page, and a control of
dropdownlist to select color of controls in the page. Then please
create theme folder of BlueTheme and PurpleTheme, and add Control.skin,
Default.css to the folders.
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.PreInit
Page.Theme = Request("ChooseTheme")
End Sub 'Page_PreInit
'Control.skin of the BlueTheme
<asp:TextBox BackColor="#c4d4e0" ForeColor="#0b12c6" Runat="Server" />
<asp:Label ForeColor="#0b12c6" Runat="Server" />
<asp:Button BackColor="#c4d4e0" ForeColor="#0b12c6" Runat="Server" />
'Control.skin of the PurpleTheme
<asp:TextBox BackColor="#ccccff" ForeColor="#602bff" Runat="Server" />
<asp:Label ForeColor="#602bff" Runat="Server" />
<asp:Button BackColor="#ccccff" ForeColor="#602bff" Runat="Server" />
|
The front end Default.aspx page looks something like this:
<fieldset>
<legend>Asp.net2.0 Theme Demo</legend>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tableStyle">
<tr>
<td colspan="2" align="center">
Select a theme of the page:
<asp:dropdownlist id="ChooseTheme" runat="server" autopostback="true">
<asp:ListItem Value="BlueTheme">Select Color</asp:ListItem>
<asp:ListItem Value="BlueTheme">Blue</asp:ListItem>
<asp:ListItem Value="PorpleTheme">Purple</asp:ListItem>
</asp:dropdownlist>
</td>
</tr><tr>
<td height="23px" class="tdStyle" colspan="2"></td>
</tr>
<tr>
<td align="center" height="52px" style="width: 513px; text-align: right;">
<asp:Label ID="Label1" runat="server" Text="Enter Your Name:" Width="141px"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" height="52px" style="width: 513px; text-align: right;">
<asp:Label
ID="Label2" runat="server" Text="Enter Your Nickname:"
Width="164px"></asp:Label> </td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" height="50px" style="width: 513px; text-align: right;">
<asp:Button ID="Button1" runat="server" Text=" OK " />
</td>
<td>
<asp:Button ID="Button2" runat="server" Text="Cancel" />
</td>
</tr>
<tr>
<td height="23px" colspan="2"></td>
</tr>
<tr>
<td colspan="2"><br /><br /></td>
</tr>
</table>
</fieldset> |
We chose Server Intellect for its dedicated servers, for our web hosting. They have managed to handle virtually everything for us, from start to finish. And their customer service is stellar.
The flow for the code behind page as follows.
Partial Class _Default
Inherits System.Web.UI.Page Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load End Sub Protected Sub Page_PreInit(ByVal sender As
Object, ByVal e As EventArgs) Handles Me.PreInit
Page.Theme = Request("ChooseTheme")
End Sub 'Page_PreInit
End Class |
|