Normally we use to have some server controls for themes selection which causes Post back. During postback the new theme value needs to be set for website. But the new value is not known at the Page_Pre_Init event to set the theme. For this we will redirect the site to the same uri with a new theme value and update the new theme to sites. Let say the user has entered and updated some values in the controls and after that if he is trying to change the theme, the user values are not persisted.
For persisting the values of control while changing the theme, the below script help you.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default"
EnableTheming="true" Theme="Theme2" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" action="Default.aspx">
<div>
<script language="javascript" type="text/javascript">
function SetPageQuery()
{
var str="default.aspx?Theme=" + document.getElementById('hdnvalue').value;
form1.action=str;
form1.submit();
}
</script>
<input id="hdnvalue" type="hidden" value="Theme1" />
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="G" Text="Theme1" Checked="true"
onclick="hdnvalue.value='Theme1';" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="G" Text="Theme2" onclick="hdnvalue.value='Theme2';" />
<input id="Button1" type="button" value="Change theme" onclick="javascript:SetPageQuery();" /><br />
<asp:TextBox ID="text1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>