You are hereBlogs / rahul's blog / Ext.Net - Invoking DirectEvents explicitly from javascript

Ext.Net - Invoking DirectEvents explicitly from javascript

rahul's picture

By rahul - Posted on 03 December 2010

I recently had a situation where I needed to invoke a DirectEvent on an Ext.Net Button explicitly. Basically, when the button was clicked, I needed to pop-up an ExtJs window (created in javascript), and depending upon the options selected on the Window, invoke DirectEvents on various Ext.Net components rendered from server.

A bit of playing around with the javascript generated by the toolkit, and it was easy to figure out. It gets as simple as this for invoking a Button DirectClick:{
    control: #{btn1}

Here, you should pass the desired Button's reference in the "control" parameter on which you need to invoke the DirectEvent.

To get a bit more complex, here's how you would invoke DirectChange event for a TextField:{
                before: txt1Before(),
                control: #{txt1},
                action: 'Change'

We did not pass "Click" for the action for Button, because that's the default for Direct events (you can pass "action" as "Click" for button too if you want to). However, "control" is the only required config option to the confirmRequest method.

Other than that, there's the required "control" reference on which the Direct Event has to be invoked, and the before method call, which if returns false, would cancel the invoking of the DirectEvent.

All other options for Ext.Net.DirectEvent that you specify through markup or in code-behind directly map to properties of the config object passed to the DirectEvent.confirmRequest method (if in doubt, check the javascript for the desired DirectEvent option generated by the toolkit).

An important point to remember is to invoke DirectEvents only on components rendered from server and which have event handlers defined in your server code. Trying to invoke DirectEvents on components instantized in javascript would raise server-side exceptions (which is obvious).

Attached is a sample file demonstrating invoking DirectEvents explicitly.




DirectEvent.aspx1.71 KB

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.

Recent comments