How do I determine which Button caused the client side event

3 posts, 0 answers
  1. Tim
    Tim avatar
    57 posts
    Member since:
    Apr 2011

    Posted 24 Jun 2011 Link to this post

    Hi

    I am using a RadToolBar with several buttons.

    I can get the client side event to fire, but I cann't figure out how
    to identify which button was clicked.

    I'm sure its obvious. :-)

    TIA
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 30 Jun 2011 Link to this post

    Hello Tim,

    You could use the following client-side event handler to display the text of the clicked button as an alert message:
    <script type="text/javascript">
            function OnClientButtonClicking(sender, args) {
                var buttontext = args.get_item().get_text();
                alert(buttontext);
            }   
        </script>

    Here is also the markup that I used for testing:
    <telerik:RadToolBar ID="RadToolBar1" runat="server" OnClientButtonClicking="OnClientButtonClicking">
               <Items>
                   <telerik:RadToolBarButton runat="server" Text="Button 0" OuterCssClass="rtbItemFocused">
                   </telerik:RadToolBarButton>
                   <telerik:RadToolBarButton runat="server" Text="Button 1" OuterCssClass="rtbItemClicked">
                   </telerik:RadToolBarButton>
                   <telerik:RadToolBarButton runat="server" Text="Button 2" OuterCssClass="rtbItemClicked">
                   </telerik:RadToolBarButton>
               </Items>
           </telerik:RadToolBar>


    All the best,
    Kate
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yohancef
    Yohancef avatar
    7 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    Hi,

    You can also use the following client-side methods:

    var

     

    item = eventArgs.get_item();

     

    item.get_value() // returns the value property of the button


    Or

    item.get_index() // returns the index of the button

Back to Top