File: DynamicThemes.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynamicThemes.aspx.cs" Inherits="DynamicThemes" Theme="ProTheme" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="lstThemes" runat="server"></asp:ListBox><br />
<br />
<asp:Button ID="cmdApply" runat="server" Text="Apply Theme" OnClick="cmdApply_Click" />
<asp:Button ID="cmdClear" runat="server" Text="Clear Theme" OnClick="cmdClear_Click" />
</div>
</form>
</body>
</html>
File: DynamicThemes.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class DynamicThemes : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DirectoryInfo themeDir = new DirectoryInfo(Server.MapPath("App_Themes"));
lstThemes.DataTextField = "Name";
lstThemes.DataSource = themeDir.GetDirectories();
lstThemes.DataBind();
}
}
protected void Page_PreInit(object sender, EventArgs e)
{
if (Session["Theme"] == null)
{
Page.Theme = "";
}
else
{
Page.Theme = (string)Session["Theme"];
}
}
protected void cmdApply_Click(object sender, EventArgs e)
{
Session["Theme"] = lstThemes.SelectedValue;
Server.Transfer(Request.FilePath);
}
protected void cmdClear_Click(object sender, EventArgs e)
{
Session["Theme"] = "";
Server.Transfer(Request.FilePath);
}
}
File: ProTheme.skin
<asp:ListBox runat="server" ForeColor="Blue" BackColor="LightYellow" />
<asp:TextBox runat="server" ForeColor="Blue" BackColor="LightYellow" />
<asp:Button runat="server" ForeColor="Blue" BackColor="LightYellow" />
|