RadRotator Not Refreshing

4 posts, 1 answers
  1. Rob
    Rob avatar
    115 posts
    Member since:
    Aug 2012

    Posted 23 Jun Link to this post

    Telerik Support,

    I have one page that has a RadGrid with a GridHyperLinkColumn.  When the user clicks the hyperlink, a second page with a RadRotator is opened up in a new browser window.  Let's say I have 2 rows of data in the grid.  If I click on the first link, the image displays as expected in the RadRotator.  Next if I click on the second hyperlink, it should set no images for the RadRotator, but instead the RadRotator's datasource seems to somehow be cached and reloads the initially loaded image. 

    Vice versa creates a similar issue.  Stop running the app and restart it.  Click on the second hyperlink first and the RadRotator is displayed with no image.  Next click on the first hyperlink and still no image is loaded.  The expected result no matter what order is selected is for the first hyperlink to display an image in the RadRotator and the second hyperlink should not display an image in the RadRotator.

    Here is a video reproducing the issue both ways with a simple example:  http://screencast.com/t/2batqcc8

    Here is the code for page 1

    ImageList.aspx

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ImageList.aspx.vb" Inherits="TestBed.ImageList" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
                <telerik:RadGrid ID="RadGrid1" runat="server" Height="100%" Width="100%" AutoGenerateColumns="false">
                    <MasterTableView>
                        <Columns>
                            <telerik:GridHyperLinkColumn DataTextField="Text" HeaderText="Image" Target="_blank" UniqueName="Text"
                                DataNavigateUrlFormatString="~\ImageViewer.aspx?image={0}" DataNavigateUrlFields="Image">
                            </telerik:GridHyperLinkColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>
            </div>
        </form>
    </body>
    </html>

    ImageList.aspx.vb

    Public Class ImageList
        Inherits System.Web.UI.Page
     
        Private Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
            Dim dt As New DataTable
            Dim dr As DataRow
            Dim col As New DataColumn("Image", GetType(Boolean))
            dt.Columns.Add(col)
            col = New DataColumn("Text", GetType(String))
            dt.Columns.Add(col)
            dr = dt.NewRow
            dr("Image") = True
            dr("Text") = "Image1"
            dt.Rows.Add(dr)
            dr = dt.NewRow
            dr("Image") = False
            dr("Text") = "Image2"
            dt.Rows.Add(dr)
            RadGrid1.DataSource = dt
        End Sub
    End Class

    ImageViewer.aspx

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ImageViewer.aspx.vb" Inherits="TestBed.ImageViewer" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
                    <telerik:RadRotator ID="RadRotator1" runat="server" RenderMode="Lightweight" DataSourceID="XmlDataSource1"
                        Width="215px" Height="100px" ItemHeight="32px" FrameDuration="2000" ScrollDuration="2000" RotatorType="Buttons">                   
                        <ItemTemplate>
                            <div class="itemTemplate">
                                <img src="<%# XPath("SmallURL") %>" alt="" style="height: 100px; width: 100px;" onclick="SetImage('<%# XPath("LargeURL") %>');" />
                            </div>
                        </ItemTemplate>
                        <ControlButtons LeftButtonID="img_left" RightButtonID="img_right"></ControlButtons>
                    </telerik:RadRotator>
                    <asp:XmlDataSource ID="XmlDataSource1" runat="server"></asp:XmlDataSource>
            </div>
        </form>
    </body>
    </html>

    ImageViewer.aspx.vb

    Public Class ImageViewer
        Inherits System.Web.UI.Page
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim image As Boolean = CBool(Me.Request.QueryString("image"))
            If image Then
                XmlDataSource1.Data = "<Data><DataItem><SmallURL>/Image1.jpg</SmallURL><LargeURL>/Image1.jpg</LargeURL></DataItem></Data>"
            Else
                XmlDataSource1.Data = "<Data><DataItem><SmallURL></SmallURL><LargeURL></LargeURL></DataItem></Data>"
            End If
        End Sub
     
    End Class

    Please help.

    Thanks,

    Rob

     

  2. Rob
    Rob avatar
    115 posts
    Member since:
    Aug 2012

    Posted 27 Jun Link to this post

    I could really use some assistance with this issue.  Thank you.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Slav
    Admin
    Slav avatar
    1356 posts

    Posted 28 Jun Link to this post

    Hello Rob,

    The examined behavior is a result of the way XmlDataSource caches its data and it is not related to RadRotator.

    By default the XmlDataSource will cache its data indefinitely, so you can either turn it of by setting its property EnableCaching to false or by setting CacheDuration and the rotator control will be configured as expected. You can find more information in the following article: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.enablecaching(v=vs.110).aspx

    Regards,
    Slav
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Rob
    Rob avatar
    115 posts
    Member since:
    Aug 2012

    Posted 28 Jun in reply to Slav Link to this post

    Thank you so much!  That fixed my problem.
Back to Top