This is a migrated thread and some comments may be shown as answers.

Style not applying on postback

4 Answers 153 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Imran Javed Zia
Top achievements
Rank 1
Imran Javed Zia asked on 30 Jan 2012, 04:16 PM
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.

4 Answers, 1 is accepted

Sort by
0
Imran Javed Zia
Top achievements
Rank 1
answered on 31 Jan 2012, 09:00 AM
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.
0
Simon
Telerik team
answered on 03 Feb 2012, 08:16 PM
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 >>
0
Imran Javed Zia
Top achievements
Rank 1
answered on 06 Feb 2012, 11:16 AM
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.
0
Simon
Telerik team
answered on 09 Feb 2012, 12:10 PM
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 >>
Tags
ScriptManager and StyleSheetManager
Asked by
Imran Javed Zia
Top achievements
Rank 1
Answers by
Imran Javed Zia
Top achievements
Rank 1
Simon
Telerik team
Share this question
or