开发者

Set StyleSheetTheme in @Page directive in ASP.NET

I have a property in asp.net application

ABPS.PRR.WEB开发者_如何学JAVA.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?


If you want to set other value to the StyleSheetTheme property of a page, you'll need to override it:

public override string StyleSheetTheme
{
    get
    {
        return ABPS.PRR.WEB.CurrentSession.Theme;
    }
    set
    {
    }
}

But if you want to change the Theme property, just set its value in the Page_PreInit event:

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


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;
}


You could set it in the code.

Put this in the Page_PreInit method.

Page.Theme = ABPS.PRR.WEB.CurrentSession.Theme

or

Page.StyleSheetTheme = ABPS.PRR.WEB.CurrentSession.Theme
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜