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.

Signature
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Michael Nemtsev [MVP] - 18 Dec 2007 09:23 GMT
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>
Jonathan Wood - 18 Dec 2007 16:56 GMT
Thanks!

Signature
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
> Hello Jonathan,
>
[quoted text clipped - 18 lines]
> JW> JW> Thanks.
> JW>
Scott Roberts - 18 Dec 2007 18:16 GMT
> 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";
}
}
}
Jonathan Wood - 18 Dec 2007 19:00 GMT
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.

Signature
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
>> But I wondered if there was any shortcut to having to set the theme in
>> the PreInit event for every single page.
[quoted text clipped - 13 lines]
> }
> }
Scott Roberts - 18 Dec 2007 19:06 GMT
The Session and User are both populated and available on the CurrentContext.
> That's cool if that will work.
>
[quoted text clipped - 25 lines]
>> }
>> }
Jonathan Wood - 18 Dec 2007 19:44 GMT
Cool. Thanks!

Signature
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
> The Session and User are both populated and available on the
> CurrentContext.
[quoted text clipped - 28 lines]
>>> }
>>> }