Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Rotator / Load On Demand

This demo shows how to use RadRotator with Load On Demand through a WebService. The rotator loads 50 items by making 10 requests which load 5 items each. New requests are not made when already loaded items should be shown again /e.g due to WrapFrames="true"/.
Configure rotator type
  • AutomaticAdvance
  • ButtonsOver
  • Buttons
  • SlideShow
  • SlideShowButtons
  • FromCode






Clear log Event log:




  • Load On Demand

    The RadRotator now supports Load On Demand functionality through a WebService. There is now a property, which determines the number of items that the request will return. This functionality is entirely controlled by the WebMethod and you can also return different number of items on each request.

    Important: Load On Demand is not supported, when RadRotator is set in carousel or coverflow mode.

    The web service should have the following signature:
    	[ScriptService]
    	public class WebServiceName : WebService
    	{
    		[WebMethod]
    		public RadRotatorItemData[] GetRotatorData(int itemIndex)
    	        {
    		    List<RadRotatorItemData> result = new List<RadRotatorItemData>();
    		    //.......
                        RadRotatorItemData item = new RadRotatorItemData();
                        item.Html = myCustomHtml;
                        result.Add(item);
                        //.......
                        return result.ToArray();
                    }
    	}
    	


    where the HTML, which should be rendered in the item, is assigned to the Html property of the RadRotatorItemData object.
    There are two client events that are related to the Load On Demand functionlity:
    • OnClientItemsRequested - fired when the items are successfully loaded
    • OnClientItemsRequestFailed - fired when the request for loading items on demand fails. The arguments provide information about the error message and allow the developer to cancel the error alert and process the error otherwise.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Rotator.LoadOnDemand.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
        <style type="text/css">
            .mainDiv
            {
                width: 100%;
                height: 220px;
            }
            .configurationPanel
            {
                width: 290px;
                height: 150px;
                border: 0px;
                float: right;
            }
            .positionCenter
            {
                margin: 8px auto;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <script type="text/javascript">

            function OnClientItemsRequested(sender, args)
            {
                logEvent("A request for items had just successfully finished! The total count of the items now is: " + sender.get_items().length);
            }

            function pageLoad()
            {
                clearLog();
            }
        
        </script>
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="Server" Transparency="30"
            EnableSkinTransparency="false" BackColor="#E0E0E0">
        </telerik:RadAjaxLoadingPanel>
        <div class="bigModule" style="margin-bottom: 40px">
            <div class="bigModuleBottom">
                This demo shows how to use RadRotator with Load On Demand through a WebService.
                The rotator loads 50 items by making 10 requests which load 5 items each. New requests
                are not made when already loaded items should be shown again /e.g due to
                WrapFrames="true"/.
            </div>
        </div>
        <telerik:RadAjaxPanel ID="AjaxPanel1" runat="server" LoadingPanelID="LoadingPanel1">
            <div style="float: left; margin: 38px 0 0 120px; border: solid 1px grey; width: 300px;
                height: 152px;">
                <telerik:RadRotator ID="RadRotator1" runat="server" Width="220px" Height="135px"
                    ItemHeight="135" ItemWidth="110" CssClass="positionCenter" ScrollDuration="500"
                    OnClientItemsRequested="OnClientItemsRequested">
                    <WebServiceSettings Path="RotatorWebService.asmx" Method="GetRotatorData" />
                </telerik:RadRotator>
            </div>
            <div style="float: right; margin-right: 50px;">
                <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Enabled="true" Title="Configure rotator type"
                    Expanded="true" HorizontalAlign="Left" Width="300" CssClass="configurationPanel">
                    <telerik:RadListBox ID="RotatorTypesList" runat="server" Width="300" AutoPostBack="true"
                        OnSelectedIndexChanged="ConfigureRotator">
                    </telerik:RadListBox>
                </qsf:ConfiguratorPanel>
            </div>
        </telerik:RadAjaxPanel>
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <div style="position: relative; margin-top: 130px;">
            <qsf:EventLogConsole ID="EventLogConsole1" runat="server" AllowClear="true" Width="830"
                Height="200" />
        </div>
        <br />
        <br />
        <br />
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451