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

3 posts, 0 answers
  1. Jes
    Jes avatar
    11 posts
    Member since:
    Mar 2016

    Posted 01 Mar Link to this post

    <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. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 04 Mar Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jes
    Jes avatar
    11 posts
    Member since:
    Mar 2016

    Posted 04 Mar Link to this post

    Thanks a lot. It helped!
Back to Top