Search code examples
asp.netthemesstylesheetpage-directives

Set StyleSheetTheme in @Page directive in ASP.NET


I have a property in asp.net application

ABPS.PRR.WEB.CurrentSession.Theme

and I'm setting it in @Page directive in aspx pages like:

<%@ Page StylesheetTheme="ABPS.PRR.WEB.CurrentSession.Theme"  Title="Default" ... %>

but I'm getting runtime error

Parser Error Message: Theme 'ABPS.PRR.WEB.CurrentSession.Theme' cannot be found in the application or global theme directories.

How can I implement this in page directive?


Solution

  • StylesheetTheme requires a theme name and you are supplying this in the wrong way.

    If you want to set the theme at runtime then you need to store it in a session variable, you can do it like...

    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.StylesheetTheme = ABPS.PRR.WEB.CurrentSession.Theme;
    }