开发者

App_Themes Not Loading on Initial Load

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 even view source and look for my css names and they are not there. I refresh and do the same thing, and they are there.

I am not usin开发者_Go百科g 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!


I found the problem. The Page_PreInit was being called before the Company information was being set during login.

So after the user logged in, that is where I called the logic to check the company details versus in the master page load.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜