Here is some sample code for dynamically changeing themes . I got this from a book I am presently reading called "Pro ASP.NET with VB.NET 2005" .
Hope you find this useful
ASPX PAGE.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DynamicThemes.aspx.vb" Inherits="Chapter15_DynamicThemes" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Applying Themes Dynamically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="lstThemes" runat="server" />
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Change Theme" />
</div>
</form>
</body>
</html>
Code Behind
Imports System.IO
Partial Class Chapter15_DynamicThemes
Inherits System.Web.UI.Page
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
If Session("Theme") Is Nothing Then
Page.Theme = String.Empty
Else
Page.Theme = Session("Theme").ToString()
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack()) Then
' Fill the listbox with available themes by reading the folders in the App_Themes folder
Dim themeDir As New DirectoryInfo(Request.PhysicalApplicationPath() & "\" & "App_Themes")
lstThemes.DataTextField = "Name"
lstThemes.DataSource = themeDir.GetDirectories()
lstThemes.DataBind()
End If
End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
' Set the chosen theme
Session("Theme") = lstThemes.SelectedValue
' Refresh the page
Server.Transfer(Request.FilePath())
End Sub
End Class