<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).
First of all, the proper RadButton event is OnClientClicked (not cancellable, postback will continue unless you set AutoPostBack="false"
) or OnClientClicking (cancellable). OnClientClick is the property name for asp:Button.
You can read more about attaching client side event handlers to Telerik AJAX controls in the following blog post: http://www.telerik.com/blogs/migrating-onclientclick-handlers-from-asp-button-to-telerik-s-asp-net-ajax-button. The gist:
use a function name as you have discovered OnClientClicked="someFunctionName"
use an anonymous function declaration OnClientClicked="function(sender, args){someFunctionName(sender, args, 'myAdditionalArguments');}"
The two event arguments are the standard MS AJAX convention where the first argument is always the object that raised the event (the RadButton instance in this case) and the second is event arguments with methods/fields as deemed appropriate by the creator of the code.
RadButton does not expose the event at the moment and if window.event
does not suit your needs, open a feature request with Telerik.