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

Styles Not Loading Properly when Control Added after Async Postback

2 Answers 173 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Shonda
Top achievements
Rank 1
Shonda asked on 15 Jun 2011, 03:10 AM
I have a page that is adding the rotator control after an async postback.
The problem is that the rotator's styles are not loading properly  when I do this.
For instance, the rrItemsList height & width are huge numbers causing it to continuously scroll to empty pages.
If I add the control and a regular postback, then the styles are fine.

2 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 15 Jun 2011, 02:40 PM
Hello Shonda,

The problem you described is caused by asynchronous loading of the skin style sheet resources through the AJAX request. You should load them with the main content to assure that they are present. There are two ways to achieve this. For the following demonstration I will use the Default skin of RadRotator, but it can be easily replaced by any of the others.

The first approach is to load the styles through a link tag using the Page.ClientScript.GetWebResourceUrl method. The link tag must be placed in the head content of the page.

<link href='<%= Page.ClientScript.GetWebResourceUrl(typeof(RadRotator), "Telerik.Web.UI.Skins.Rotator.css") %>' rel="stylesheet" type="text/css" />
<link href='<%= Page.ClientScript.GetWebResourceUrl(typeof(RadRotator), "Telerik.Web.UI.Skins.Default.Rotator.Default.css") %>' rel="stylesheet" type="text/css" />


The other way is to use the RadStyleSheetManager. Note that you must register a HttpHandler in web.config. This can be done automatically through Smart Tag, available in Design View.
Here you can find more information about using RadStyleSheetManager.

<telerik:RadStyleSheetManager ID="StyleSheetManager1" runat="server">
     <StyleSheets>
           <telerik:StyleSheetReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Skins.Rotator.css" />
           <telerik:StyleSheetReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Skins.Default.Rotator.Default.css" />
      </StyleSheets>
</telerik:RadStyleSheetManager>

Either of the two solutions will help you solve your problem. If you want to use another skin you must put its name instead of Default at the marked places.

The attached project contains both implementations. Main.aspx uses the first approach and Default.aspx - the second.

Kind regards,
Slav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Shonda
Top achievements
Rank 1
answered on 16 Jun 2011, 01:27 AM
That worked.

Thank you so much.
Tags
Rotator
Asked by
Shonda
Top achievements
Rank 1
Answers by
Slav
Telerik team
Shonda
Top achievements
Rank 1
Share this question
or