RadRotator ignoring unique target URLs

5 posts, 1 answers
  1. Bruce
    Bruce avatar
    8 posts
    Member since:
    Dec 2011

    Posted 14 Mar 2012 Link to this post

    I am using a RadRotator control to display a series of images, and each image has a unique target URL that the user is to be redirected to when clicked.

    What I encountering is that the ImageButton contains the properties of the last image in the Rotator. When I look at the sender object in the code-behind, the ImageURL and AlternateText property are set to the last image loaded into the Rotator, not the values of the image I clicked.

    How can I get this to work ?? I was using a asp:Hyperlink control initially in the RadRotator, but the same problem was occuring.


    Here is my code:


                            <telerik:RadRotator ID="RadRotator1" runat="server" DataSourceID="SqlDataSourceHomeImages" FrameDuration="4000" RotatorType="AutomaticAdvance"  >
                                <ItemTemplate>
                                        <asp:ImageButton ID="btnHomePage" runat="server" ImageUrl='<%# "images/" & Eval("hpi_image")%>'  AlternateText='<%# Eval("hpi_URL") %>' OnClick="btnHomePage_Click"/>
                                          </ItemTemplate>
                            </telerik:RadRotator>

                            <asp:SqlDataSource ID="SqlDataSourceHomeImages" runat="server" ConnectionString="<%$ ConnectionStrings:WebDB_string.com%>"
                                    SelectCommand="SELECT hpi_image, hpi_URL, hpi_external FROM tbl_HomeImages WHERE hpi_show_on_web = 'True' ORDER BY hpi_sort_order">
                            </asp:SqlDataSource>

    And here is the Click event from the code-behind:

       Protected Sub btnHomePage_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs)

            Response.Redirect(sender.AlternateText)

        End Sub

    Very simple, and it should work. But it doesn't and it's driving me crazy !!

    Thanks !

    Bruce

  2. Answer
    Slav
    Admin
    Slav avatar
    1355 posts

    Posted 19 Mar 2012 Link to this post

    Hi Bruce,

    Please check the attached sample page and verify if there are differences in the configuration, something that I am missing in order to reproduce the problem.

    Note that you can achieve the same effect by placing an ASP Image control instead of an ImageButton in the RadRotator's items and handling its event OnItemClick. This way you can also reference the clicked item and its content.

    The steps, listed in the help article How to configure RadRotator, are recommended for configuring the rotator control properly, as I noticed that you have not specified size for the RadRotator and its items.

    If you are still having difficulties after examining the provided information, please describe the changes that should be made to the attached page so that the issue can be reproduced or provide a reliable steps for recreating your problem so that I can examine it locally.

    Kind regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bruce
    Bruce avatar
    8 posts
    Member since:
    Dec 2011

    Posted 19 Mar 2012 Link to this post

    Thank you, thank you, thank you !!!

    The example was exactly what I needed. Not sure why it was working previously, but it's working now.

    Thanks for your help !!

    Bruce
  5. Bruce
    Bruce avatar
    8 posts
    Member since:
    Dec 2011

    Posted 19 Mar 2012 Link to this post

    Uh-oh. I spoke to soon.

    It is working perfectly in IE, Firefox and Chrome, but the images are not rotating in Safari. Any ideas why this would be happening and how to correct it ??
  6. Bruce
    Bruce avatar
    8 posts
    Member since:
    Dec 2011

    Posted 19 Mar 2012 Link to this post

    I had set the Height and Width properties, but not the ItemHeight and ItemWidth. Once those were set, it rotated correctly in all browsers.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017