Home » Microsoft » MB6-704 » What should you use to define the code for the event handler?
You have a class named Class l that has a public method named methodl.
For method1, you plan to create an event handler that is defined in the Application Object Tree (AOT).
For the event handler, you need to develop code that runs after method l executes.
What should you use to define the code for the event handler?
A. A display method on a table
B. A static method on a class
C. The new method on a class.
D. A public instance method on a class
Correct Answer: B
Explanation/Reference:
All event handlers that subscribe to a method must return void.
Event handlers for host methods can use one of two parameter signatures:
One parameter of the type XppPrePostArgs
The same parameters that are on the host method that the event handler subscribes to The following code shows an example of an event handler that has the XppPrePostArgs class as the only parameter.
X++ static public void myEventHandler(XppPrePostArgs _ppArgs) {
// Add useful code here.
}
Note:
* In the AOT, you can assign a method as an event handler for the pre-method event or the post-method event of another method. We say the event handler subscribes to an event of the host method.
The nodes that represent the subscription of an event handler to a host method are underneath the node for the host method. AOT elements such as classes, tables, and forms can have methods.
* You can subscribe methods as event handlers in two locations in the Application Object Tree (AOT):
• Under a delegate node
• Under a method node
Reference: Event Handler Nodes in the AOT [AX 2012]