How to change skin by coding for all page

6 posts, 0 answers
  1. Big Q
    Big Q avatar
    30 posts
    Member since:
    Jan 2010

    Posted 26 Oct 2010 Link to this post

    Hi telerik team,
    I have a OA system which has many pages (use frame, not masterpage),  it allowed user to choose skin which they like, and save it to database. When he login next time, system read the setting from database and set it to all the pages.
     
    Above is what I want, but I have a problem:
    first , I don't want to put the RadSkinManager to each page and write code " RadSkinManager.GetCurrent(this.Page).Skin=Session["UserSkin"]; "  on Page_Load(object sender, EventArgs e){} method,  because I have too many pages.
    second: I don't want to put the RadSkinManager to an usercontrol, and drag it to every page.

    Is there any other ways to implement my ideal, such as new a RadSkinManager in BasePage and let other pages inherit it ? Or let every control's skin property empty and change the default skin setting which was writen in web.config before page load ? Or some other way? How should I do ?

    By the way, I write some code on Page_Load Method, it doesn't work....

    protected void Page_Load(object sender, EventArgs e)
    {
        Telerik.Web.UI.RadSkinManager skinManager = new Telerik.Web.UI.RadSkinManager();
        skinManager.Skin = "Forest";
    }


    Thanks very much.
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 27 Oct 2010 Link to this post

    Hello Big Q,

    First of all, please try not to post duplicate forum threads with the same question.

    http://www.telerik.com/community/forums/aspnet-ajax/skin-manager/new-an-radskinmanager-but-it-doesn-t-work.aspx

    You don't have to set the RadSkinManager's Skin property on every page - you can use the control's ability to store the skin name in the session automatically by setting PersistenceMode="Session". So you can set the control's Skin property only once, when the user logs in. However, you do need the RadSkinManager on every page.

    Yes, you can use a custom base class for your pages and add a RadSkinManager to the page in the base class.

    Greetings,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Big Q
    Big Q avatar
    30 posts
    Member since:
    Jan 2010

    Posted 27 Oct 2010 Link to this post

    haha , I got it just now, below is my way

    Create a BasePage.cs inherit from system.web.ui.page, and all the other page inherit it

    protected override void OnPreInit(EventArgs e)
    {
       base.OnPreInit(e);        
       RadSkinManager skinManager = new RadSkinManager();
       skinManager.Skin = xxxx    //here will be read from database
       Page.Controls.Add(skinManager);
      
       RadFormDecorator dd = new RadFormDecorator();
       Page.FindControl("form1").Controls.Add(dd);  
    }

    so it is with the RadFormDecorator , but it should use Page.FindControl("form1").Controls.Add() ,
    otherwise it will cause an error, because of the added code in html is at the outer of </html> tag
  5. Big Q
    Big Q avatar
    30 posts
    Member since:
    Jan 2010

    Posted 27 Oct 2010 Link to this post

    hi,
    I am sorry for posting duplicate forum threads,it won't be happen again.

    "you can use the control's ability to store the skin name in the session automatically by setting PersistenceMode="Session". ”
    "So you can set the control's Skin property only once, when the user logs in"

    sorry, I am not understand what you mean clearly, I find a property named "PersistenceKey" with a default value "Telerik.Skin",  is this the key of Session ?
    if you  means when user login, I should read her skin setting from db, and set the Session[Telerik.Skin] = GetSkinSetting(userid) ,
    and then new a  RadSkinManager, add it to page, it will find the session automatically ?
  6. Big Q
    Big Q avatar
    30 posts
    Member since:
    Jan 2010

    Posted 27 Oct 2010 Link to this post

    I solved above question. But another one puzzled me, it's about RadFormDecroator

    When I drag a FromDecorator in to page in the design environment, I can set the "DecoratedControls" property with mulity value, like this:
    <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server"  DecoratedControls="Default, Textbox, Textarea" />,
    But I don't know how to implement it by codeing? I can only do this:
    formDecorator.DecoratedControls = FormDecoratorDecoratedControls.Textbox;
    it cann't be given mulity values.....could you please tell me how to achieve it ?
  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 01 Nov 2010 Link to this post

    Hi Big Q,

    The DecoratedControls property is enum and you can set its options through server code using the following syntax:

    formDecorator.DecoratedControls = FormDecoratorDecoratedControls.Textbox | FormDecoratorDecoratedControls.CheckBoxes | FormDecoratorDecoratedControls.Textarea;

    Best regards,
    Rumen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017