The Asp.net| creation action is a class of components that inherit from the Sys.action base class in ASP.net atlas to implement a class of event-handling capabilities that are raised by an event. The action is similar to the function of the event handler, but it is a generalized event-handling component that describes some common, common event-handling methods, such as invoking a method, setting a property of an object, triggering a postback, and so on.
we all know that, so far, the best reference manual for Atlas is its source code. We can find the following three kinds of built-in action for Atlas from the source code, all of which inherit from the Sys.action base class:
sys.invokemethodaction: Used to invoke a specified function.
set.setpropertyaction: A property value that is used to set an object.
Sys.WebForms.PostBackAction: Used to raise a postback.
in actual projects, it is often not enough to use only the three built-in action, and we usually need to define some of the action that is commonly used in the project. Fortunately, creating a custom action will be a very simple thing to do in Atlas's complete architecture. Let's familiarize ourselves with the method of customizing the action with a simple alertaction example. When a specified event is raised, Alertaction is displayed to the user with a JavaScript prompt dialog box containing the specified text.
Typically, creating a custom action has the following four steps:
inherits from the Sys.action base class.
defines the properties of your action class. In the alertaction example, we need to specify a message property to hold the content that will be displayed to the user.
Implement the Performaction () method to perform the custom actions you want. This method will be invoked automatically by the action base class. In our example, we simply use the built-in alert () function in JavaScript to pop up the dialog box and display the contents of the message property.
for your custom action to add the associated type description in the GetDescriptor () method.
Below is the alertaction JavaScript code. The above four steps are marked in the code as comments. Save the following code as alertaction.js.
sys.alertaction = function () {
Sys.AlertAction.initializeBase (this);
//Step 2
var _message;
this.get_message = function () {
return _message;
}
this.set_message = function (value) {
_message = value;
}
//Step 4
this.getdescriptor = function () {
var td = Sys.AlertAction.callBaseMethod (this, ' getdescriptor ');
Let's test this alertaction on the page. The only button that needs to be added to the page is to trigger our alertaction. The following is the HTML definition in the ASPX file. Don't forget to add a reference to the Alertaction.js file in ScriptManager.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.