1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Improving performance of RadRotator

Improving performance of RadRotator

5 posts, 0 answered
  1. Richard
    Richard avatar
    16 posts
    Registered:
    14 Apr 2009
    17 Jun 2009
    Link to this post
    We are using a RadRotator on our homepage to display images and text content (pulled from an xml file using an XmlDataSource). Using the SlideShowButtons RotatorType.
    The problem is that the RadRotator loads all of its content straight away, rather than pulling it down as needed. This makes the homepage load quite slow.

    Is there a better way to achieve this, which would just load one image (and associated text) at a time via AJAX methods?

    I'd also prefer if the content was pulled from a Lists module rather than the xml file, so that at least it's within Sitefinity.

    Also would like to be able to randomize the content that is shown.

    thanks

    Richard
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    18 Jun 2009
    Link to this post
    Hi Richard,

    All items are loaded straight away as you have noticed. The control does not support partial loading, but we have plans for this. I believe that application debug has been set to false in your web.config file on the production.

    If you want to use the control under Sitefinity there is no problem to add it as it is now bounded to your XmlDataSource. If you want to use it in context of Sitefinity you can upload the imaged through Images and Documents module. Then you can create ObjectDataSource control

    <asp:ObjectDataSource ID="odsImages" runat="server"  
        TypeName="Telerik.Cms.Engine.ContentManager"  
        SelectMethod="GetContent"  
        StartRowIndexParameterName="from"  
        MaximumRowsParameterName="max"  
        SortParameterName="sortExp" 
        onobjectcreating="odsImages_ObjectCreating"   
        onselecting="odsImages_Selecting">  
    </asp:ObjectDataSource> 

    Then you can add the following logic for odsImages_ObjectCreating and odsImages_Selecting

        protected void odsImages_ObjectCreating(object sender, ObjectDataSourceEventArgs e) 
        { 
            _libraryManager = new Telerik.Libraries.LibraryManager(); 
            ContentManager man = new ContentManager("Libraries"); 
            e.ObjectInstance = man; 
        } 
     
        protected void odsImages_Selecting(object sender, System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs e) 
        { 
             
            System.Guid[] myArray = { LibraryId }; 
            e.InputParameters.Add("from", 0); 
            e.InputParameters.Add("max", ImageMax); 
            e.InputParameters.Add("parentIDs", myArray); 
            // You can sort the items or not 
            //string sortExpr = "Name ASC"; 
            //e.Arguments.SortExpression = sortExpr; 
        } 

    As you see from the last 3 lines of the code you can specify whether to sort the content items or not. Another option is using System.Random class.

    Random random = new Random(); 
    IContent randomImage = (IContent)content[random.Next(0, content.Count - 1)]; 


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Richard
    Richard avatar
    16 posts
    Registered:
    14 Apr 2009
    23 Jun 2009
    Link to this post
    Hi Ivan

    Thanks for your reply. I think that is the direction I'd like to take this control in however I couldn't get it to work using the code you sent.

    When using the XmlDataSource I am able to display the image using:
    <asp:Image ID="Image1" runat="server" ImageUrl='<%# XPath("image") %>' /> 

    What should this be now? Sorry, but it's been a long time since I've developed web apps so am a bit rusty!

    Wasn't sure why you thought application debug has been set to false in my web.config - I checked and it isn't!

    Richard
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    23 Jun 2009
    Link to this post
    Hi Richard,

    Could you send the code you have using my approach( if it is a user control - send us the control template and code behind). I will try to see why the items does not appear for you.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    30 Apr 2010
    Link to this post
    I just noticed that you can put "NEWID()" in the sort expression to randomize the result. It is built into SQL Server and worked!
Register for webinar
5 posts, 0 answered