Ok, I changed my BasePage and ThemeSelector. ThemeSelector now sets Globals.ThemeSelectorID to the UniqueID of the ImageButton. However, this.Theme = this.Request.Form[id]; and this.Session and ["CurrentTheme"] = this.Theme; are still Null.
Do I need to change thos code since I am now using a ImageButton, not a drop down list?
if (this.Request.Form["__EVENTTARGET"] == id &&
!string.IsNullOrEmpty(this.Request.Form[id]))
Code:
namespace RC.RPC_Group.UI
{
public class BasePage : System.Web.UI.Page
{
protected override void OnPreInit(EventArgs e)
{
string id = Globals.ThemesSelectorID;
if (id.Length > 0)
{
// if this is a postback caused by the theme selectors dropdownlist,
// retrieve the selected theme and unse it for the current page request
if (this.Request.Form["__EVENTTARGET"] == id &&
!string.IsNullOrEmpty(this.Request.Form[id]))
{
this.Theme = this.Request.Form[id];
this.Session["CurrentTheme"] = this.Theme;
}
else
{
if (this.Session["CurrentTheme"] != null)
this.Theme = this.Session["CurrentTheme"].ToString();
}
}
base.OnPreInit(e);
}
}
}
Code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using RC.RPC_Group;
namespace RC.RPC_Group.UI.Controls
{
public partial class ThemeSelector : System.Web.UI.UserControl
{
string themeName = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Globals.ThemesSelectorID.Length == 0)
Globals.ThemesSelectorID = blueMidnight.UniqueID;
}
protected void blueTheme_Box_Click(object sender, ImageClickEventArgs e)
{
themeName = "blueMidnight";
Globals.ThemesSelectorID = blueMidnight.UniqueID;
}
protected void redTheme_Box_Click(object sender, ImageClickEventArgs e)
{
themeName = "maroonBlood";
Globals.ThemesSelectorID = maroonBlood.UniqueID;
}
protected void goldTheme_Box_Click(object sender, ImageClickEventArgs e)
{
themeName = "goldLabel";
Globals.ThemesSelectorID = goldLabel.UniqueID;
}
}
}