I am trying to use a RadRotator control inside an aspnet UpdatePanel. The RadRotator displays a set of images whenever the user clicks a button. It works as expected in IE 9, but when I view the page in Firefox (version 13.0.1), the RadRotator width is set to 0 on the first postback. It will display on subsequent postbacks -- just not the initial one.
The develomplent is in VS 2010, and the version of the Telerik library is 2011.3.1115.40.
Here is a simplified example of the ASPX file and CodeBehind that is causing the issue:
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ImageRotatorTest.WebForm1" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:UpdatePanel runat="server" ID="up1">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadRotator ID="itemsRotator" runat="server" Width="600px" Height="118px"
ItemHeight="108" ItemWidth="81" WrapFrames="false" RotatorType="Buttons" ScrollDuration="1" FrameDuration="1"
Visible="False" >
<ItemTemplate>
<asp:Image runat="server" Height="108" Width="81" BorderStyle="Solid" BorderColor="DarkGray" BorderWidth="1" ID="JobImage" ImageUrl='<%# Eval("ImagePath") %>' />
</ItemTemplate>
</telerik:RadRotator>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
CodeBehind:
namespace ImageRotatorTest
{
public partial class WebForm1 : System.Web.UI.Page
{
class RotatorImage
{
public RotatorImage(string imagePath)
{
ImagePath = imagePath;
}
public string ImagePath { get; set; }
}
protected void Button1_Click(object sender, EventArgs e)
{
DisplayRotator();
}
private void DisplayRotator()
{
List<RotatorImage> imageList = new List<RotatorImage>();
imageList.Add(new RotatorImage("Images/Squirrel.jpg"));
imageList.Add(new RotatorImage("Images/Squirrel.jpg"));
imageList.Add(new RotatorImage("Images/Squirrel.jpg"));
itemsRotator.Visible = true;
itemsRotator.DataSource = imageList;
itemsRotator.DataBind();
}
}
}
The problem seems to be stemming from the fact that the RadRotator visibility is initially set to false, because when it is initially set to true the problem disappears. Unfortunately, I need to initially hide the RadRotator until the user clicks a button. Also, eliminating the UpdatePanel is not an option because we have other code that depends on it. Please help.
Thanks,
Scott Howard
The develomplent is in VS 2010, and the version of the Telerik library is 2011.3.1115.40.
Here is a simplified example of the ASPX file and CodeBehind that is causing the issue:
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ImageRotatorTest.WebForm1" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:UpdatePanel runat="server" ID="up1">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadRotator ID="itemsRotator" runat="server" Width="600px" Height="118px"
ItemHeight="108" ItemWidth="81" WrapFrames="false" RotatorType="Buttons" ScrollDuration="1" FrameDuration="1"
Visible="False" >
<ItemTemplate>
<asp:Image runat="server" Height="108" Width="81" BorderStyle="Solid" BorderColor="DarkGray" BorderWidth="1" ID="JobImage" ImageUrl='<%# Eval("ImagePath") %>' />
</ItemTemplate>
</telerik:RadRotator>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
CodeBehind:
namespace ImageRotatorTest
{
public partial class WebForm1 : System.Web.UI.Page
{
class RotatorImage
{
public RotatorImage(string imagePath)
{
ImagePath = imagePath;
}
public string ImagePath { get; set; }
}
protected void Button1_Click(object sender, EventArgs e)
{
DisplayRotator();
}
private void DisplayRotator()
{
List<RotatorImage> imageList = new List<RotatorImage>();
imageList.Add(new RotatorImage("Images/Squirrel.jpg"));
imageList.Add(new RotatorImage("Images/Squirrel.jpg"));
imageList.Add(new RotatorImage("Images/Squirrel.jpg"));
itemsRotator.Visible = true;
itemsRotator.DataSource = imageList;
itemsRotator.DataBind();
}
}
}
The problem seems to be stemming from the fact that the RadRotator visibility is initially set to false, because when it is initially set to true the problem disappears. Unfortunately, I need to initially hide the RadRotator until the user clicks a button. Also, eliminating the UpdatePanel is not an option because we have other code that depends on it. Please help.
Thanks,
Scott Howard