The Beauty of ASP.NET 2.0 Themes in Visual Studio 2005 - How to apply ASP.NET 2.0 themes at runtime: creating theme and skin
(Page 5 of 6 )
We can also set the theme of a page during run time. This concept is useful for allowing users to customize the page according to their preference or interest.
Let us go through an example of setting a theme during runtime (we shall use the same design and controls discussed in previous sections)
1. Modify the properties of the button as follows:
a. Text=”First Theme”
b. ID=”btnFirstTheme”
2. Place another button (ASP.NET server control) and modify the following properties:
a. Text=”Second Theme”
b. ID=”btnSecondTheme”
3. Create one more Theme (named “SecondTheme”) by just following the steps discussed in the previous sections. By this time, your solution explorer should look something like the following image, fig7.

4. Add a new skin (“SkinFile.skin”) to the newly created theme (“SecondTheme”) by just following the steps discussed in the previous sections.
5. Open “SkinFile.skin” file and type the following code:
<asp:Button
runat="server"
BackColor="AliceBlue"
BorderColor="Black"
BorderStyle="Solid"
BorderWidth="1px"
/>
<asp:Button
runat="Server"
SkinId="btnSecondTheme"
BackColor="#FFE0C0"
BorderColor="#C04000"
BorderStyle="Solid"
BorderWidth="1px"
/>
<asp:ListBox
runat="server"
BackColor="green"
BorderColor="white"
BorderStyle="Solid"
BorderWidth="1px"
/>
<asp:ListBox
runat="server"
SkinId="lstSkinBlue"
BackColor="steelblue"
BorderColor="black"
BorderStyle="Solid"
BorderWidth="1px"
/>
Next: How to apply ASP.NET 2.0 themes at runtime: working with code >>
More ASP.NET Articles
More By Jagadish Chaterjee