Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Rotator > Determine which link was clicked inside RadRotator

Answered Determine which link was clicked inside RadRotator

Feed from this thread
  • Ronnie avatar

    Posted on Feb 9, 2012 (permalink)

    I have a RadRotator with 2 different LinkButtons inside the template.  Each LinkButton has a command argument that is pulled from the database.  What is the easiest way to determine which LinkButton was clicked in the Rotator_ItemClick event?  The problem that I am having is that I can't determine which LinkButton was clicked so that I can execute specific server side code.  

    <telerik:RadRotator ID="RadRotator1" runat="server"
        DataSourceID="dsProducts" RotatorType="CoverFlowButtons" Skin="Forest" Width="625px"
        Height="350px" ItemHeight="350px" ItemWidth="551px" PauseOnMouseOver="true"
            BorderStyle="None">
        <ItemTemplate>
            <asp:LinkButton ID="lnkAddTestimonial" runat="server" CommandName="AddTestimonial"
            CommandArgument='<%# Eval("ProductID") %>'>Add Review</asp:LinkButton>
            <asp:LinkButton ID="lnkViewTestimonials" runat="server" CommandName="ViewTestimonials"
            CommandArgument='<%# Eval("ProductID") %>'>Read Reviews</asp:LinkButton>
        </ItemTemplate>
    </telerik:RadRotator>

    Reply

  • Answer Kevin Master avatar

    Posted on Feb 13, 2012 (permalink)

    Hello Ronnie,

    You should create a separate event handler for the two LinkButtons. So you create a single event handler called Testimonial_Command and attach it to both of the buttons. Like so:

    ASPX:
    <telerik:RadRotator ID="RadRotator1" runat="server"
        DataSourceID="dsProducts" RotatorType="CoverFlowButtons" Skin="Forest" Width="625px"
        Height="350px" ItemHeight="350px" ItemWidth="551px" PauseOnMouseOver="true"
            BorderStyle="None">
        <ItemTemplate>
            <asp:LinkButton ID="lnkAddTestimonial" runat="server" CommandName="AddTestimonial"
            CommandArgument='<%# Eval("ProductID") %>' OnCommand="Testimonial_Command">Add Review</asp:LinkButton>
            <asp:LinkButton ID="lnkViewTestimonials" runat="server" CommandName="ViewTestimonials"
            CommandArgument='<%# Eval("ProductID") %>' OnCommand="Testimonial_Command">Read Reviews</asp:LinkButton>
        </ItemTemplate>
    </telerik:RadRotator>

    Code:

    protected void Testimonial_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "AddTestimonial")
        {
            // do this
        }
        else if (e.CommandName == "ViewTestimonial")
        {
            // do this instead
        }
    }

    I hope that helps.

    Reply

  • Ronnie avatar

    Posted on Feb 13, 2012 (permalink)

    That is perfect, exactly what I was looking to do.  Thanks so much.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Rotator > Determine which link was clicked inside RadRotator
Related resources for "Determine which link was clicked inside RadRotator"

[  ASP.NET Rotator Features  |  Documentation  |  Demos |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]