ASP event Design

Source: Internet
Author: User

Author's blog: http://blog.csdn.net/oyiboy/
The reason why I want to Develop ASP with MVC is to turn process-oriented thinking into object-oriented thinking. This is good for developers in any language.
MVC is a standard model. It seems very difficult to implement ASP, but the standard is standard and the application is used. Since ASP is difficult to implement this model, then we can try to transform the MVC model into a suitable model.
"No matter whether the white cat or the black cat can catch the mouse, it's a good cat ." For our developers, no matter what the model is, it can correctly guide our ideas. A perfect project model is a good model. After all, users use our products. Program Instead of our model.
During this time, due to the access to MVC, I also learned how to use the class and encountered the design of the event.
In fact, I am not quite clear about the specific event design method. newskyline told me in QQ that ASP cannot perform class events,
It can only be simulated. What about me. It is not a means to achieve the purpose (write the Program), think the simulation is good, non-simulation is also good, as long as the effect I want is good.
There are two ways to simulate an event:
First, execute/Eval is used to collect the function name characters with an attribute, and execute/Eval is used to run the function.
For example:
OBJ. ondataupdatestart = "checkdata"
Its structure is as follows:
Public property let ondataupdatestart (byval a_strvalue)
''Here, some rigorous verification of a_strvalue is omitted. Code .
P_strondataupdatestart = a_strvalue
End Property

The event is triggered as follows:
Public sub dataupdate ()
''... Ignore the process...
Execute (p_strondataupdatestart & "(Parameter Variable 1, parameter variable 2 )")
''... Ignore the process...
End sub
A little bit of difference between execute and eval.
The same "x = Y ". Execute ("x = y") assigns the Y value to X, and eval ("x = y") returns a Boolean value, indicates the test results of X and Y. If X is equal to Y, true is returned. Otherwise, false is returned.
Type 2: Borrow the function pointer getref. In the vbs manual, the function is bound to the event-specific function. The specific explanation is as follows:
"A reference pointing to a process is returned. This process can be bound to an event ."
Example:
OBJ. ondataupdatestart = "checkdata"
Its structure is changed:
Public ondataupdatestart ''can actually use the get/let mode. If you want to be lazy, you can directly declare a public variable to pass it.
The event trigger is changed:
Public sub dataupdate ()
''... Ignore the process...
Set me. ondataupdatestart = getref (ondataupdatestart)
Me. ondataupdatestart ("parameter variable 1", "parameter variable 2 ")
''... Ignore the process...
End sub
The above two methods can be used to bind events, but in terms of interpretation, I prefer the second method, which is more rigorous than execute/eval.
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.