Button click from inside a rotator

9 posts, 1 answers
  1. SonicImaging
    SonicImaging avatar
    88 posts
    Member since:
    Jan 2007

    Posted 18 Oct 2008 Link to this post

    Hi,  im trying to catch a click event from inside the rotator but the events arent being fired.  Is there an example I can look at?  I can catch the click event for the rotator just not the items inside.

    I have a rotator that is inside a user control with 2 link buttons and an image.  I can catch the click event on a button in the usercontrol outside the rotator just not inside.

    Thanks
    -Keith
  2. SonicImaging
    SonicImaging avatar
    88 posts
    Member since:
    Jan 2007

    Posted 18 Oct 2008 Link to this post

    I sorted out my control loading issues so now I can get the click events on any control inside my usercontrol but outside the radrotator

    So im back to the point of not being able to trap the click event of the radrotator in my usercontrols codebehind or anything inside the radrotator for that matter. If I can get the click in the rotator I can get the rest from there.

    The usercontrol is being loaded with loadcontrol in the contents page pre_init but the radrotator is placed in the usercontrol  why wouldnt the onitemclick event not be fire just for the radrotator if its being fire for everything else outside that?  im using the onitem click from the radcontrol demo

    Thanks
    -Keith
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SonicImaging
    SonicImaging avatar
    88 posts
    Member since:
    Jan 2007

    Posted 19 Oct 2008 Link to this post

    Hi,  I'm getting the correct event from the radrotator onclick now.   It was a literal control being added to a div in codebehind instead of adding it to a placeholder.  The control was being added before the content place holder.  Still not sure why that would affect the events so much but its working correctly now.

    Im still facing 2 issues

    1)  I have a rotator with an image and 2 link buttons.   If I set a debug point in the onintemclick of the rotator I get the event fine when any  items are clicked on,  but how can I figure out which control inside the rotator was clicked?  since one of the link buttons and the image will pop up a radwindow and the other linkbutton will add the product to a cart.

    2)The image and one of the linkbuttons pop up a radwindow,  if I have the onitemclick set in the rotator and click the link the rad window comes up and then goes away, im assuming that its because the rad window is activated from javascript but then the event continues to the rotator click event and that causes a post back killing the window.  I think if I can get number 1) working I can open the rad window from the itemclick of the rotator and the window will stay since its all happening on the same postback.

    Thanks
    -Keith
  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Oct 2008 Link to this post

    Hello Keith Niemyjski,

    On the server you can get only the index of the item - e.Item.Index. I am not quite sure what exactly you want to achieve, but I would suggest to consider using the server click event of the corresponding control that you click itself.

    As for your second question, how exactly do you open the RadWindow? From your explanation it seems that you are opening it with JavaScript from a postback element. In such scenario however you must cancel the postback of this element by returning false. Another reason might be that you have enabled the postback for RadRotator and open RadWindow from the server's click event for the postback element - this way you will get 2 postbacks which will again remove the window immediately after showing.


    Regards,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. SonicImaging
    SonicImaging avatar
    88 posts
    Member since:
    Jan 2007

    Posted 21 Oct 2008 Link to this post

    Hi,  I think im still dealing with a event bubbling issues in my project.  So just so i know how it should work.

    1)     If the rotator frame is clicked on in the background then I should get a single event to the itemclick of the rotator
    2)     If a control is clicked on in the rotator frame then I should get 2 events,  one to the rotators click event and one to the controls click event
    3)     If my link with the javascript window open is clicked in the frame and if I have the javascript return false then just the radwindow will open and all other events will be canceled.

    Is this the correct behavior?  This is exactly what I need but this is where I have a problem with the events in this project.   The only way for me to get the individual events from the controls inside the frame is to remove the onclick event from the rotator.  If there is a onclick in the rotator then only that gets fired and somehow that cancels any other events following.  I think that the root of my problem.

    Like my other issue with the control being added to a div and not a placeholder I think ive got something else going on.  (its a project Im taking over from someone else so something is causing this to act this way)

    Thanks for clearing that up for me
    -Keith
  7. Answer
    Lini
    Admin
    Lini avatar
    2144 posts

    Posted 24 Oct 2008 Link to this post

    Hello Keith,

    Here is a small example I made with your case:

    <script type="text/javascript"
    function openRadWindow(e) 
        //open radwindow here 
        alert(1); 
        $telerik.cancelRawEvent(e); 
    </script> 
     
    <telerik:RadRotator DataSourceID="XmlDataSource1" ID="RadRotator1" runat="server" 
        ItemWidth="300px" Width="300px" ItemHeight="300px" Height="300px"
        <ItemTemplate> 
            <asp:LinkButton ID="linkButton1" runat="Server"
        <img src='<%# XPath("Image") %>' alt=""/> 
        <%# XPath("Text") %> 
            </asp:LinkButton> 
            <asp:LinkButton ID="linkButton2" OnClientClick="openRadWindow(event);return false" 
                runat="Server">Test window open</asp:LinkButton> 
        </ItemTemplate> 
    </telerik:RadRotator> 

    The example features a rotator with two link buttons in the item template. One of the link buttons posts back to the server, while the other opens a new window without posting back. In this case you do not need a rotator ItemClick event, because both the image and the text are included in the first link button - clicking either of them will initiate a postback from the link button.

    The second link button does not postback. I have achieved this by adding "return false;" after the function call in the OnClientClick property and by canceling the event bubbling using one of our client-side API functions (cancelRawEvent).

    If you add an ItemClick event with the above rotator configuration here is what will happen:
    - clicking on the first link button (image or text) will produce two postbacks - one for the rotator item click event and one for the link button.
    - clicking on the second link button (window open) will not make a postback because we cancel the event bubbling up to the rotator item.

    If you still experience problems after using the above example, please open a formal support ticket and send us a sample project and tell us what you think is wrong with it. We will do our best to help you fix it.

    Kind regards,
    Lini
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. SonicImaging
    SonicImaging avatar
    88 posts
    Member since:
    Jan 2007

    Posted 25 Oct 2008 Link to this post

    Thanks for the tips.  I did get my events in order in my project so its all working as it should.

    I found I needed to use $telerik.cancelRawEvent(e); to make sure it stops any other events so thats all working when I open a radwindow



    -Keith


  9. Wayne Elliott
    Wayne Elliott avatar
    1 posts
    Member since:
    Feb 2005

    Posted 15 Feb 2011 Link to this post

    I have the same problem I am experiencing. 

    Where and how do I use $telerik.canceRawEvents?  I have been chasing the problems for the last couple days and did not find this in any documentation.

    Can you please provide specific information for handling the numerous postback to the server.

    Thank you.

  10. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 18 Feb 2011 Link to this post

    Hi Wayne,

    This thread is quite old so I am not quite sure what exactly is the problem that you currently experience. Could you please provide more information on your exact case?


    Best wishes,
    Georgi Tunev
    the Telerik team
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017