For a session with hands on part i tryed to build a extended ASP.NET Themes example.
The goal is that the user can select the theme. Thats all, not much or?
But as murphey always says ....
1) i created two themes
2) i created a strongly typed attribute in profile section of web.config
<profile >
<properties>
<add name="theme" type="string" defaultValue="DevTrain" allowAnonymous="true" />
</< SPAN <>< SPAN>properties>
</< SPAN <>< SPAN>profile>
2) tryed to put a master page ( which i need in any case) and set the theme
But: Theme must pe set in preinit event and master page doesnt have preinit
3) Tryed to use a page base class and code the prinit event. The page base can be set in web.config
<pages pageBaseType="...">
The baseclass must inherit from page and be placed in app_code
4) now the problems begins realy. The Profile Class is not availaible in base class. Do not know why. I found some tipps to use acquirequeststate event from global.asax. Doesnt work. Another tipp was to build a httphandler.
But i found a better and easier way. 1 line of code
5. Use the preinit event of the page base class. Access the profile with httpcontext AND access the profile in a "latebindinding" matter with the item property. Profile.Theme doesnt work.
theme=httpcontext.current.profile.item("theme").tostring
Thats all. A perfect day.