Encounter ASP class of event design

Source: Internet
Author: User
Tags eval implement net variable
Design

Author's blog: http://blog.csdn.net/oyiboy/

The reason I'm still advocating MVC to develop an ASP is to make the process-oriented thinking way into an object-oriented way of thinking, which is good for developers of any language.
MVC is a standard model, the ASP to implement seems to be really difficult, but the standard is the use of, since the ASP to implement this model is difficult, it can try to change the MVC model to form a suitable model.
"No matter white cat black cat can catch a mouse is a good cat." "And for US developers, no matter what the model, can correctly guide our thinking, the perfect model of the project is a good model." After all, users end up using our programs rather than our models.

This period of time because of exposure to MVC, but also know how class is used, encountered the design of the event.

In fact, the specific design of the event I am not very clear, in the QQ Newskyline told me that the ASP can not do class events,

can only simulate. And I do. is to achieve the goal is not the means (write program), think that simulation is good, not simulation also line, as long as I want to achieve the effect is the best thing.

  There are two ways to simulate events:

  First: Borrow the Execute/eval, use a property to charge the character of the function name, and then use Execute/eval to run the function.
Such as:
Obj. Ondataupdatestart= "Checkdata"
The structure is:
Public Property Let Ondataupdatestart (ByVal a_strvalue)
' This omits some rigorous validation code for A_strvalue.
P_strondataupdatestart=a_strvalue
End Property
    
Event is triggered as:
Public Sub Dataupdate ()
'... Ignore procedure ...
Execute (P_strondataupdatestart & "(parameter variable one, parameter variable II)")
'... Ignore procedure ...
End Sub
Mention the difference between execute and eval a little bit.
The same "X=y". The result of execute ("X=y") is that the Y value is assigned to X, and eval ("X=y") returns a Boolean value that represents the test result for X and Y, which returns true if X equals Y, and vice versa.

  The second: Borrowing function pointer getref, in the context of the VBS manual, is the binding event-specific function. The specific explanations are as follows:

"Returns a reference to a procedure that can bind an event. ”
Examples of specific applications, such as:
Obj. Ondataupdatestart= "Checkdata"
Its structure is changed to read:
Public Ondataupdatestart ' actually can use Get/let mode, want to be lazy, so directly declare an open variable to pass.

The event trigger is changed to:
Public Sub Dataupdate ()
'... Ignore procedure ...
Set me. Ondataupdatestart=getref (Ondataupdatestart)
Me. Ondataupdatestart ("parameter variable One", "parameter variable two")
'... Ignore procedure ...
End Sub

The above two ways to achieve event binding, but, in terms of interpretation, I prefer the second, relative to the execute/eval more rigorous.







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.