This is a migrated thread and some comments may be shown as answers.
How do I determine which Button caused the client side event
2 Answers 21 Views
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 24 Jun 2011, 06:45 PM
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 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 30 Jun 2011, 11:08 AM
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.

0
Yohancef
Top achievements
Rank 1
answered on 30 Jun 2011, 07:50 PM
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

Asked by
Tim
Top achievements
Rank 1
Answers by
Kate
Telerik team
Yohancef
Top achievements
Rank 1
Share this question
or