DotNet Tutorials

Server Intellect

 User Selectable Themes in ASP.NET and C#

Tutorial showing how you can let your users choose how a page looks, using ASP.NET Themes. C# version. For this example, there will be three simple themes to choose from, and they will be chosen from a drop-down menu.
First, add an ASP.NET folder > Theme for each theme you will create. Within each of these folders, you will need a CSS file and a Skin file.
Example CSS file:

We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect's help, we were able to avoid any headaches!

td.title
{
font-size: 1em;
text-align: center;
font-family: verdana;
font-size: x-large;
font-weight: bolder;
color: Navy;
}
table.header
{
background-color: #cee9ff;
}
h1
{
font-size: large;
color: Navy;
}
h2
{
font-family: Verdana;
font-size: medium;
margin-top: 30;
color: Navy;
}
p
{
font-family: Verdana;
font-size: small;
color: Navy;
text-align: left;
}
hr
{
border: 0;
border-top: 2px solid Navy;
height: 2px;
}

Example skin file:

<asp:dropdownlist runat="server" ForeColor="white" BackColor="Blue" />

Master Page:

<form id="form1" runat="server">
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="header">
<tr>
<td class="title">Switchable Themes Example</td>
</tr>
<tr>
<td><hr /></td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td><hr /></td>
</tr>
</table>
</form>

If you're ever in the market for some great Windows web hosting, try Server Intellect. We have been very pleased with their services and most importantly, technical support.


Content ASPX page:

<%@ Page Language="C#" MasterPageFile="~/Master1.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="User Selectable Themes" StylesheetTheme="Blue" %>

<script runat="server">
public void Page_PreInit()
{
// Sets the Theme for the page.
this.Theme = "Blue";
if (Request.Form != null && Request.Form.Count > 0)
this.Theme = this.Request.Form[4].Trim();
}
</script>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1 id="title1">Switchable Themes on a Page</h1><br />
<h2 id="title2">
This is a custom page within a master page.</h2>
<p>Choose from the drop-down menu below to change the color of this page.</p>
<br /><br />
<asp:dropdownlist id="changeThemes" runat="server" autopostback="true">
<asp:listitem value="Blue">Change the page to blue!</asp:listitem>
<asp:listitem value="Red">Change the page to red!</asp:listitem>
<asp:listitem value="Green">Change the page to green!</asp:listitem>
</asp:dropdownlist>
</asp:Content>


Looking for the VB.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!

We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect's help, we were able to avoid any headaches!
Download Project Source - Enter your Email to be emailed a link to download the Full Source Project used in this Tutorial!



100% SPAM FREE! We will never sell or rent your email address!
 
123 ASP

411 ASP

Dot Net Freaks

Server Intellect