App_Themes Not Loading on Initial Load

Posted by Jason Heine on Stack Overflow See other posts from Stack Overflow or by Jason Heine
Published on 2010-06-14T18:31:40Z Indexed on 2010/06/14 18:32 UTC
Read the original article Hit count: 141

Filed under:
|
|

Hello,

I have an application where different users can log in via a single portal login. When they log in, if they belong to more than 1 company they have to select the company they belong to. The theme will change if there is a custom theme for that company.

Each page my application has inherits a "CustomPage" class

Here is the code for the custom page:

public class CustomPage : Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Globals.Company != null && Directory.Exists(Page.MapPath("~/App_Themes/" + Globals.Company.CompanyName)))
        {
            Page.Theme = Globals.Company.CompanyName;
        }
        else
        {
            Page.Theme = "Default";
        }
    }
}

When the customer belongs to more than 1 company, and they select the company they belong to, the theme loads just fine.

So, the problem I am having is this:

If they belong to just 1 company, the company is automatically selected but the theme does not load right away. However, if I refresh the page, the theme loads just fine. Even the default theme will not load. The page has no css at all until I refresh.

I am not using forms authentication and the default theme in the web config is "Default"

<pages theme="Default">

Any thoughts to what might be going on? If you need clarification on anything, please ask.

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET