Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
User Selectable Themes in ASP.NET and C# (0 Comments)
Admin: Posted Date: April 4, 2010

Tutorial showing how you can let your users choose how a page looks, using ASP.NET Themes. C# version.Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services.

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:


 

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:

 

Master Page:






Switchable Themes Example






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.

Content ASPX page:



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

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();
}




Switchable Themes on a Page



This is a custom page within a master page.

Choose from the drop-down menu below to change the color of this page.




Change the page to blue!
Change the page to red!
Change the page to green!

 

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: