Style not applying on postback

5 posts, 0 answers
  1. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 30 Jan 2012 Link to this post

    Hi,

    I have implemented stylesheetManager for my application.
    I am trying to set different theme on postback i.e. by adding css files dynamically.

    here is sample code:

    private void AddStyleSheets(RadStyleSheetManager styleSheetManager)
            {
                styleSheetManager.StyleSheets.Clear();
      
                if (SessionManager.CurrentSessionManager.PageTheme.ToLower().Equals("tone"))
                {
                    styleSheetManager.StyleSheets.Add(new Telerik.Web.UI.StyleSheetReference("SNet.RTO.Skins.TOne.ComboBox.css", "SNet.RTO.Skins.TOne"));
                }
                else
                {
                    styleSheetManager.StyleSheets.Add(new Telerik.Web.UI.StyleSheetReference("CustomSkins.ComboBox.css", "CustomSkins"));
                }
      
                styleSheetManager.ApplyStyleSheetSkin(Page);
            }

    I am calling above method on Page's Init event.

    Style is set on first time load only and never works after postback. I have read following post but of no use.
    http://www.telerik.com/community/forums/aspnet-ajax/scriptmanager-and-stylesheetmanager/stylesheetmanager-does-not-update-head-section-after-ajax-postback.aspx

    Any help? Thanks in anticipation.
  2. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 31 Jan 2012 Link to this post

    We are using Q2 2011 SP1. I thought its missing in my original post. So I am posting it now.
    Any help? Thanks in anticipation.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 03 Feb 2012 Link to this post

    Hi Imran,

    It will be very difficult to investigate this without more details and/or a sample project. Does this happen after an AJAX postback or a regular one? In which browsers does it happen?

    Additionally, please provide a link to a sample project, which I can inspect.

    Greetings,
    Simon
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 06 Feb 2012 Link to this post

    Hi, 

    It's AJAX postpack. The below sample project is not working either. So you may use this as the sample project.

    http://www.telerik.com/ClientsFiles/243401_StyleSheetCombiningAfterAjax.zip


    Thanks.
  6. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 09 Feb 2012 Link to this post

    Hello,

    The controls in the project are verison 2010.3 1109.35 and the functionality works fine there. With version Q2 2011 SP the functionality breaks because the Sunset.css file has been moved to the Skins assembly. So, the fix is to the change the name of the containing assembly:
    if (Page.IsPostBack)
                RadStyleSheetManager1.StyleSheets.Add(new Telerik.Web.UI.StyleSheetReference() { Assembly = "Telerik.Web.UI.Skins", Name = "Telerik.Web.UI.Skins.Sunset.Rotator.Sunset.css" });

    As a conclusion, please make sure that the style sheets you are referencing in your real project exist the specified containing assemblies.

    Regards,
    Simon
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017