doface (original work)
When talking about ASP, many people think that it is a collection of HTML scripts, some codes enclosed in <% and %>, and some JAVASCRIPT scripts. Such code, and then Adding all kinds of comments in different formats, it looks like one word: chaos. It doesn’t matter whether others can understand it or not, as long as it can achieve its own purpose, because the ASP code is also a script, it is impossible for customers to not see the content. It is often included in a part of the business in the DLL. Logic, but I still feel that ASP code is the least valuable code. No one goes back to buy it. You can always get the unique style of stuff that others have worked hard to write by viewing the source code from other people's websites. These reasons have made ASP develop into a code that is easy to write and forget quickly. The readability and maintainability are also the worst among various languages.
In fact, ASP code can also be object-oriented and modular like other languages. Many pages can be integrated and encapsulated into a class, and different methods in the class can be used to display different pages. In this way, you can combine pages under the same business logic with The logic is encapsulated into a class and implemented using different methods. Having said so much, maybe everyone’s ideas are confused. Let me give you some examples:
<%
'****************************************
'* Class name: clsWebWorkFlowLog
'* Function :Workflow log tracking class
'* History:
'* Created by: doface
'* Date: 2003/10/24 Ver 1.0
'* Changes:
'* Date:
'**************** ***********************
class clsWebWorkFlowLog
'Define public properties to store Connection objects
public ActiveConnection
privateoResponse
'========================================
'= process name: main
'= Parameters:
'= Function: main calling function
'= perform different operations based on different action parameters
'= return value:
'========================================
sub main()
select case Request("act")
case "list"
list()
case else
list()
end select
end sub
'========================================
'= process name: list
'= Parameters:
'= Function: Display list screen
'= return value:
'========================================
sublist()
oR
set oRs = ActiveConnection.execute("select *,(select name from wf_config where id=w.wf_id) as wfname from wf_log w where step_id=1 and user_id=" & session("usr")("uid"))
'(select * from wf_log where id in (select max(id),wf_id,tab_id,rec_id from wf_log group by wf_id,tab_id,rec_id where wf_id= and tab_id=))
%> <p align="left"><img border="0" src="../images/desk/workflow-new.gif" WIDTH="32" HEIGHT="32"><font color="# FF0000"><b>To-do items:</b></font></p>
<center>
<table bgColor="#FFFFFF" border="1" borderColorDark="#ffffff" borderColorLight="#c0c0c0" cellSpacing="0" width="99%" height="25">
<tr>
<td bgColor="#808080" height="15"><font color="#FFFFFF">Process Name</font></td>
<td bgColor="#808080" height="15"><font color="#FFFFFF">Applicant</font></td>
<td bgColor="#808080" height="15"><font color="#FFFFFF">Application time</font></td>
<td bgColor="#808080" height="15"><font color="#FFFFFF">Completion time</font></td>
<td bgColor="#808080" height="15"><font color="#FFFFFF">Status</font></td>
<td bgColor="#808080" height="15"><font color="#FFFFFF">Operation</font></td>
</tr><%
do while not oRs.eof
dim maxID,Next_id
if glbFunc.getMaxID(oRs("id").value,ActiveConnection,maxID,Next_id) then
%><tr>
<td bgColor="#ffffff" height="19"><%=oRs("wfname")%></a></td>
<td bgColor="#ffffff" height="19"><%=session("usr")("name")%> </td>
<td bgColor="#ffffff" height="19"><%=oRs("exetime")%> </td>
<td bgColor="#ffffff" height="19"> </td>
<td bgColor="#ffffff" height="19"><%=glbFunc.getCurZT(oRs("id").value,ActiveConnection)%></td>
<td bgColor="#ffffff" height="19"><p align="left"><a href="../PubExeTab/PubExeTab.asp?act=view&tab_id=<%=oRs("tab_id")% >&id=<%=oRs("rec_id")%>"><img src="../images/action/view.gif" border="0" alt="Details" WIDTH="16" HEIGHT=" 16"></a> <a href="javascript:newin('wfimage.asp?act=list&id=<%=oRs("wf_id")%>&bz=1&step_id=<%=next_id%>', true,false,false,false,true);"><img src="../images/action/lcchuli.gif" border="0" alt="Process Tracking" WIDTH="16" HEIGHT="16" ></a> </p></td><%
end if
%></tr><%
oRs.movenext
loop
%></table>
</center>
<%
end sub
end class
'****************************************
'* End of class
'****************************************
'******************************************
'ASP page starts
'****************************************
'Output standard HTML header
glbFunc.writeHEAD
dim oWebWorkFlowLog
set oWebWorkFlowLog = new clsWebWorkFlowLog
set oWebWorkFlowLog.ActiveConnection = glbFunc.getADOConnection
oWebWorkFlowLog.main
glbFunc.writeTail()
%>
More methods can be added so that this one class can complete the functions of multiple previous ASP files. When accessing, you can distinguish it by adding parameters (which function you want to access) after .ASP.