Search code examples
asp.netcssthemestelerikskin

How do I change ASP.NET App_Themes based on what Skin is selected in RadSkinManager?


How do I change ASP.NET App_Themes based on what Skin is selected in RadSkinManager?

I have a RadSkinManager dropdownlist in my masterpage that allows users to select their own skin provided by Telerik Rad Controls. I want to be able to switch my App_Theme directory so that all my other CSS and asp.net .skin files change along with the RadSkin as well.

Is there a "best practice" for this?


Solution

  • You need to store the users selected theme and set the Page.StyleSheetTheme property.

    .NET profiles would work well for your described scenario. Create a UI Theme property and set the page StyleSheetTheme or Theme. Control the theme via your base page.

    See http://msdn.microsoft.com/en-us/library/2y3fs9xs.aspx for creating profile properties.

    Profile property sample:

    <profile>
      <properties>
        <group name="UI">
          <add name="Theme" type="System.String" defaultValue="DefaultThemeName" />
        </group>
      </properties>
    </profile>
    

    Accessing the property:

    ProfileCommon profile = new ProfileCommon().GetProfile(HttpContext.Current.User.Identity.Name);
    Page.StyleSheetTheme = profile.UI.Theme;
    

    Lastly, use your RadSkinManager dropdown list to set the theme for the user profile.