This is a migrated thread and some comments may be shown as answers.

How can I get the mouse event object if I attach the client event inline?

2 Answers 130 Views
Button
This is a migrated thread and some comments may be shown as answers.
Jes
Top achievements
Rank 1
Jes asked on 01 Mar 2016, 06:43 AM

<telerik:RadButton runat="server" ID="testButton" OnClientClick="onclicktestbutton" />
<script type="text/javascript">
function onclicktestbutton(sender, args) {
// I don't use window.event (it is non-standard)
}
</script>


Where can I set the event object??
I wanted to do it like this:

<telerik:RadButton runat="server" ID="testButton" OnClientClick="onclicktestbutton(event)" />

but we all know you can't insert paragraph on a telerik client event attribute because it automatically includes in the function the parameters (sender, args).

 

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Mar 2016, 06:31 AM
Hi Jes,

Please note that the event is called OnClientClicked instead of OnClientClick. And you can access the event using the following method:
<telerik:RadButton runat="server" ID="testButton" OnClientClicked="onclicktestbutton" />
<script type="text/javascript">
    function onclicktestbutton(sender, args) {
        // I don't use window.event (it is non-standard)
        var event = args.get_domEvent();
    }
</script>

Also, you can examine the sample provided in the following post to see how you can pass custom parameters:
http://www.telerik.com/forums/onclientclicked-with-parameters#3q1RrpymbkeurVVA4BmKxg

I hope this will prove helpful. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jes
Top achievements
Rank 1
answered on 04 Mar 2016, 07:28 AM
Thanks a lot. It helped!
 
Tags
Button
Asked by
Jes
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Jes
Top achievements
Rank 1
Share this question
or