Changing the Skin Codebehind

4 posts, 0 answers
  1. Roger
    Roger avatar
    38 posts
    Member since:
    May 2008

    Posted 30 Jun 2011 Link to this post

    If I set ShowChooser="True", my selected skin is persisted.

    Rather than having just the name of the skin, I wanted a sample image as well, so I pulled the skin images from and put in a combo, but when I change the skin it's selected value isn't persisted.

    I have two formdecorators, one for my page work area, and one for the area outside the working area of the page where I change the background.

    When I change the skin, the standard controls aren't updated either.
    Me.RadSkinManager1.Skin = Skin
    'Attempt to update all controls on the page, which doesn't seem to do anything.
    Me.RadSkinManager1.ApplySkin(Me.Page.Form, Skin)
    Me.RadFormDecorator1.Skin = Skin
    Me.RadFormDecorator2.Skin = Skin

    <telerik:RadSkinManager ID="RadSkinManager1" Enabled="True" PersistenceKey="TelerikSkin"
        PersistenceMode="Cookie" ShowChooser="false" runat="server" />

  2. Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 06 Jul 2011 Link to this post

    Hi Roger,

    Currently the Skin of the RadSkinManager is persisted only if the Skin is changed through the built-in SkinChooser.
    To achieve your goal, you have two options:
        - To set the ShowChooser property to true and use built-in cmobobox. Then on Page_Load you should be able to find this combobox by ID and change its Items collection:
    RadComboBox chooser = Page.FindControl("SkinChooser") as RadComboBox;

        - To create your own SkinManager control which inherits the RadSkinManager as in the above sample. The on SelectedIndexChanged of your custom chooser call the ChangeSkin method.

    Kind regards,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 15 Dec 2011 Link to this post

    [EDIT dec-15-2011] See last paragraph of this note for a solution.

    I'm not getting this one to work with Q11/3/1115.
    I have a dropdown combobox with a limited selection of skin names.
    On selectedindex_changed I have
    string skin = ddSkin.SelectedItem.Text;

    skinner is of type MySkinManager which is defined in another DLL inheriting from RadSkinManager.
    public class MySkinManager : RadSkinManager
        public new void ChangeSkin( string skin )

    The page markup then has this...

    <%@ Register Assembly="MyControls" Namespace=""
      TagPrefix="my" %>
    <form id="form1" runat="server">
          <my:MySkinManager ID="skinner" runat="server" Enabled="true" />
          <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
          <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" />
          <telerik:RadAjaxManager ID="RAM1" runat="server">
              <telerik:AjaxSetting AjaxControlID="ddSkins">
                  <telerik:AjaxUpdatedControl ControlID="skinner" />
                   <telerik:AjaxUpdatedControl ControlID="pnlPage" />

    So a change to the ddSkins drowdown updates MySkinManager skinner, and I also update the entire page which is nested under pnlPage.

    [EDITED dec-15-2011]

    My default skin is WebBlue, identified in web.config.  It looks like no matter which skin I try to change to, the page (pnlPage) seems like it loses its skinning.  When this happens, the dropdown looks like it has it's fonts corrupted, changes to the selected index have no further affect on the screen, and the styles in the rest of the page aren't attractive. I can go back to WebBlue but I can't change to any other skin - it's as though none of the other skins have been pre-loaded. Do we need to specify the possible skins that we might be using at compile time so that they are available at runtime? If I set the default to Forest or any SkinX, I get the same behavior - anything other than SkinX shows up weird, and going back to the original SkinX looks great.  Wherever possible I have set EnableViewState=true, EnableAjaxSkinRendering=true, EnableEmbeddedSkins=true, and EnableTheming=true. (That's just a shotgun approach to try to find what's wrong.) I've even added my RadFormDecorator as an AjaxUpdatedControl. But none of that seems to help.

    Does anyone see what's wrong with the way that's written?

    Also, I don't understand why we have to inherit from RadSkinManager rather than just invoking ChangeSkin on that object.


    [EDIT dec-15-2011] I remembered that I already had code to do this in the form of a RadPageStylist server control. Looking back I found a reference to (Telerik's) Vladimir Enchev's blog where he describes how to do this. Note, the code link on the blog page is bad but the Live Demo works. I have the code for my purposes but it would be better if Telerik fixed that link. This is my solution, but it would be nice if Telerik made this a little more elegant.
  4. Tsvetina
    Tsvetina avatar
    2376 posts

    Posted 19 Dec 2011 Link to this post


    Thanks for pointing our direction to the broken link in this blog post. We will investigate what is wrong there and provide a working link.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top