8.3. Store Themes in User ProfilesNote: Allowing users to select a theme is one thing, but you need to be able to remember their preferences so that when they return, their choice remains the one they selected. In the previous lab, Section 8.2, you saw how to make it possible for your users to change the theme of a page dynamically. The technique is fine as far as it goes, but the next time the user visits your site, she will have to select the theme again. Instead of asking a user to select a theme every time she visits your site, it is better for you to store the user's preferred theme in the Profile object. 8.3.1. How do I do that?Note: The Profile object is used to personalize a site or a user. Use the Profile object to remember a user's preferences. In this lab, you will use the Profile object to store the theme selected by the user. When the user visits the page again, the theme is then retrieved from the Profile object and reapplied to the page.
8.3.2. What about......applying themes at the application level? You can apply a theme to an entire application by adding the <pages> element in Web.config: <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <pages theme="Colorful" /> </system.web> </configuration> In the previous example, pages that do not have the Theme attribute in the Page directive will use the Colorful theme. If a page has the Theme attribute set, it will override the settings in Web.config. 8.3.3. Where can I learn more?To learn more about the Profile service, refer to Chapter 7, where I discuss in more detail how to use the Profile service for authenticated and anonymous users. |