The author's blog: http://blog.csdn.net/oyiboy/
The reason why I still advocate using MVC to develop ASP is just to turn the process-oriented thinking method into an object-oriented thinking method, which is beneficial to developers of any language.
MVC is a standard model. It seems that it is really difficult to implement ASP, but the standard is the standard, and application is the application. Since it is difficult for ASP to implement this model, you can try to transform the MVC model into a model that suits you.
"No matter what the white cat is, the black cat can catch a mouse, it is a good cat." For us developers, no matter what model it is, it can correctly guide our thinking, and a model that perfectly completes the project is a good model. After all, users end up using our program rather than our model.
During this period, because I came into contact with MVC, I also knew how to use Class and encountered the design of events.
Actually, I don’t understand the specific event design method very well. Newskyline told me in QQ that ASP cannot do Class events.
Simulation can only be done. And what about me. It is considered a means to achieve the goal (writing the program). It is considered that simulation is good or not, as long as the effect I want is good.
There are two ways to simulate events:
The first type: borrow execute/eval, use an attribute to collect the character of the function name, and then use execute/eval to run the function.
like:
obj.OnDataUpdateStart="CheckData"
Its structure is:
publicpropertyletOnDataUpdateStart(byvalA_strValue)
'' Some rigorous verification code for A_strValue is omitted here.
p_strOnDataUpdateStart=A_strValue
endproperty
The event is triggered as:
publicsubDataUpdate()
''...Ignore the process...
execute(p_strOnDataUpdateStart&"(parameter variable one, parameter variable two)")
''...Ignore the process...
endsub
Let me briefly mention the differences between execute and eval.
The same "x=y". The result of execute("x=y") is to assign y value to x, while eval("x=y") will return a Boolean value, representing the test results of x and y. If x is equal to y, it will return true, otherwise it will return false.
The second type: borrowing the function pointer GetRef. According to the explanation of the vbs manual, it is a function dedicated to binding events. The specific explanation is as follows:
"Returns a reference to a process that binds an event."
Specific application examples, such as:
obj.OnDataUpdateStart="CheckData"
Its structure is changed to:
publicOnDataUpdateStart '' can actually use the get/let mode. I want to be lazy, so I directly declare a public variable to pass it.
The event trigger is changed to:
publicsubDataUpdate()
''...Ignore the process...
setme.OnDataUpdateStart=GetRef(OnDataUpdateStart)