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

Click event from JavaScript

1 Answer 778 Views
Button
This is a migrated thread and some comments may be shown as answers.
Chaitanya
Top achievements
Rank 1
Chaitanya asked on 31 Aug 2012, 08:56 AM
Hi,
In our application we are trying to assign shortcut keys for options on the screen,
which requires us to trap keys on client side and accordingly call .click() event of targetted control.
We have some validations set for all these controls in OnClientClicking event.
According to validation conditions we have to stop postback by setting arguments.setCancel(true). Also, on some places we 
need to open rad window pop up after setting postback false.

Issue that we are facing is when we fire click event of these controls using mouse OnClientClicking is being called, but
when we are trying to achieve same by firing .click() from javascript for short cut keys functionality, OnClientClicking is not getting
called.

Please let me know if you have any solution for this. Or some other way to achieve our functionality.

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 04 Sep 2012, 08:01 PM
Hello Chaitanya,

Truly, when click event of RadButton is called programmatically via the .click() method, the OnClientClicking event is not fired, which is the expected behavior. Nevertheless, you can easily accomplish your scenario without this event. My suggestion is to insert a confirm dialog check before the client-side click takes place as the example below demonstrates:
function ProgramClick() {
    var btn = $find("<%=myButton.ClientID %>");
    if (confirm('Ok to continue this action?')) {
        btn.click();
    }
}

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Button
Asked by
Chaitanya
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or