Is it possible to tie an application theme to a particular user or user group?
I have a lot of B2B customers and I would like use their logo/color scheme during their shopping session.
App_Theme
App_Theme
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com
AC7 User http://www.SchoolSupplyStore.com
Re: App_Theme
Well ASP.NET provides ways to change the theme through code. For this you have to set the Page.Theme property in the Page_PreInIt event handler like below
You can give a try in your pages by first checking the user group or any other criteria for which you want to change the theme and then set theme accordingly.
Code: Select all
protected void Page_PreInit(object sender, EventArgs e)
{
Page.Theme = "theme name";
}
Re: App_Theme
You can also put this in your Global.asax (notice how I am using the affiliate mobile number field to store the theme to avoid messing with the database schema):
Code: Select all
// this event is executed for every page request
// and is run before the PreInit event. Therefore we
// can use it to set the theme and master for every page
protected void Application_PreRequestHandlerExecute(object sender, System.EventArgs e)
{
// cast the current handler to a page object
Page page = HttpContext.Current.Handler as Page;
if (page != null)
{
// add an event handler for the PreInit event (the master page needs to be set there)
page.PreInit += new EventHandler(Custom_PreInit);
}
}
void Custom_PreInit(object sender, EventArgs e)
{
// cast the current handler to a page object
Page page = HttpContext.Current.Handler as Page;
if (page != null)
{
if (!Request.FilePath.StartsWith("/Admin/") &&
Token.Instance.User.Affiliate != null && Token.Instance.User.Affiliate.MobileNumber != String.Empty)
page.Theme = Token.Instance.User.Affiliate.MobileNumber;
}
}
Basem Emara:
http://BasemEmara.com
http://BasemEmara.com