Hello,
I use trial version of Web UI Controls & Components for ASP.NET AJAX. I’ve faced a problem with RadRotator animation. I use it in Web User Control. Here is the code for my control FabricItunes.ascx :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FabricItunes.ascx.cs" Inherits="test.Controls.FabricItunes" %><%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %><style type="text/css"> .rotWrapper { margin-left: auto; margin-right: auto; height: 260px; font-family: Arial; padding: 190px 0 0; width: 750px; background: #fff url("travel_back.jpg") no-repeat 0 0; font: 14px 'Segoe UI' , Arial, Sans-serif; color: #000; } .RemoveRotatorBorder div.rrClipRegion { /* The following style removes the border of the rotator that is applied to the items wrapper DIV of the control by default, in case the control renders buttons. In case you want to removed this border, you can safely use this CSS selector. */ border: 0px none; }</style><telerik:RadRotator ID="RadRotator1" runat="server" Width="575px" ItemWidth="140px" Height="130px" ItemHeight="86px" FrameDuration="100000" PauseOnMouseOver="False" RotatorType="CoverFlow" CssClass="RemoveRotatorBorder" Skin="Web20" WrapFrames="False" onitemclick="RadRotator1_ItemClick"> <ItemTemplate> <asp:Image ID="Image1" runat="server" ImageUrl='<%# Container.DataItem %>' AlternateText="<%# VirtualPathUtility.GetFileName(Container.DataItem.ToString()) %>" /> <asp:Label ID="Label1" runat="server" Text="<%# VirtualPathUtility.GetFileName(Container.DataItem.ToString()).Substring(0, 3) %>"></asp:Label> </ItemTemplate></telerik:RadRotator><script type="text/javascript"> //<![CDATA[ // The set_scrollAnimationOptions method takes two arguments - the first one is the ClientID of the rotator, which we want to configure and the second one is // a hash table with the options we want to apply. Telerik.Web.UI.RadRotatorAnimation.set_scrollAnimationOptions("<%= RadRotator1.ClientID %>", // The ClientID of the RadRotator { minScale: 0.8, // The size scale [0; 1], applied to the items that are not selected. yO: 60, // The offset in pixels of the center of the selected item from the top edge of the rotator. xR: -30, // The offset in pixels between the selected items and the first item on the left and on the right of the selected item. xItemSpacing: 50, // The offset in pixels between the items in the rotator. matrix: { m11: 1, m12: 0, m21: -0.1, m22: 1 }, // The 2d transformation matrix, applied to the items that appear on the right of the selected item. reflectionHeight: 0.5, // The height of the reflection reflectionOpacity: 1 // The opacity, applied to the reflection } ); // end of animationOptions //]]></script>
The code behid is:
namespace test.Controls{ public class FabricChoosedEventArgs : EventArgs { private string _FabricCode; public string FabricCode { get { return _FabricCode; } set { _FabricCode = value; } } } public partial class FabricItunes : System.Web.UI.UserControl { public delegate void FabricChoosedEventHandler(object sender, FabricChoosedEventArgs e); public event FabricChoosedEventHandler OnFabricChoosed; string virtualPath = "~/Images/Fabrics/"; private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { FabricColorID = 0; ConfigureRadRotator(FabricColorID); } } public void ConfigureRadRotator(int FabricColorID) { RadRotator1.RotatorType = RotatorType.CoverFlow; RadRotator1.DataSource = GetFilesInFolder(virtualPath, FabricColorID); RadRotator1.InitialItemIndex = 0; RadRotator1.DataBind(); } protected List<string> GetFilesInFolder(string folderVirtualPath, int FabricColorID) { testws ws = new testws(); List<string> FL = new List<string>(); FL = ws.FabricsByColor(FabricColorID).ToList(); List<string> virtualPathsCollection = new List<string>(); foreach (String path in FL) { string virtualPath = VirtualPathUtility.AppendTrailingSlash(folderVirtualPath) + System.IO.Path.GetFileName(path) + "_th.jpg"; virtualPathsCollection.Add(virtualPath); } return virtualPathsCollection; } protected void RadRotator1_ItemClick(object sender, RadRotatorEventArgs e) { Label lbl = e.Item.FindControl("Label1") as Label; if (this.OnFabricChoosed != null) { FabricChoosedEventArgs r = new FabricChoosedEventArgs(); r.FabricCode = lbl.Text; this.OnFabricChoosed(this, r); } } }}Now when I place this web user control on Web Form Using Master Page it loads perfectly with needed animation effects firs time. But when I click a rotator item it causes page post back and rotator loses all its animation effects.
Here is the code for Web Form:
<%@ Page Title="" Language="C#" MasterPageFile="~/Shop.Master" AutoEventWireup="true" CodeBehind="Shop.aspx.cs" Inherits="test.Shop" %><%@ Register src="Controls/BuyItem.ascx" tagname="BuyItem" tagprefix="uc1" %><%@ Register src="Controls/FabricItunes.ascx" tagname="FabricItunes" tagprefix="uc2" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_MainArea" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"> <ContentTemplate> <uc3:BuyItem ID="BuyItem1" runat="server" /> </ContentTemplate></asp:UpdatePanel><div id="pnlProductItunes"> <asp:UpdatePanel runat="server" UpdateMode="Always"> <ContentTemplate> <div style="height: 155px; margin-top: 35px;"> <uc2:FabricItunes ID="FabricItunes" runat="server" /> </div> </ContentTemplate> </asp:UpdatePanel></div></asp:Content>The code behid is:
namespace test{ public partial class Shop : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.FabricColors.OnFabricColorChoosed += new test.Controls.FabricColors.FabricColorChoosedEventHandler(FabricColors_OnFabricColorChoosed); this.FabricItunes.OnFabricChoosed += new test.Controls.FabricItunes.FabricChoosedEventHandler(FabricItunes_OnFabricChoosed); } void FabricItunes_OnFabricChoosed(object sender, Controls.FabricChoosedEventArgs e) { this.BuyItem1.showFabricImage(e.FabricCode); } }}Please advise how to avoid this animation loosing.
Thanks in advance for any suggestion.