User-Specified Themes

J

Jonathan Wood

If I want each user to be able to specify their own themes, does that mean I
must set the theme in an even handler (such as PreInit) for every single
page?

I suppose I could cache the user's theme in the Session object. But I
wondered if there was any shortcut to having to set the theme in the PreInit
event for every single page.

Thanks.
 
M

Michael Nemtsev [MVP]

Hello Jonathan,

yes u must

see there http://quickstarts.asp.net/QuickStartv20/aspnet/doc/themes/personalization.aspx

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


JW> If I want each user to be able to specify their own themes, does
JW> that mean I must set the theme in an even handler (such as PreInit)
JW> for every single page?
JW>
JW> I suppose I could cache the user's theme in the Session object. But
JW> I wondered if there was any shortcut to having to set the theme in
JW> the PreInit event for every single page.
JW>
JW> Thanks.
JW>
 
S

Scott Roberts

But I wondered if there was any shortcut to having to set the theme in the
PreInit event for every single page.

You can set the theme in Application_PreRequestHandlerExecute in
global.asax:

private void Application_PreRequestHandlerExecute(Object sender, EventArgs
e)
{
HttpContext CurrentContext = HttpContext.Current;
Page p = ( CurrentContext.Handler as Page );
if ( null != p )
{
p.Theme = "Default";
}
}
}
 
J

Jonathan Wood

That's cool if that will work.

One thing: my plan is to cache the user's theme in the Session object. So
this code will need to be able to access both the Session object and some
database code. I assume the database code will work but now I wonder if the
Session object will be available. I would also need to get info for the
current user, which may not be set up either.

I'll have to play around with that.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top