Many people think that ASP is a collection of HTML scripts and some code included in <% and %>, and some JAVASCRIPT scripts and other code, this Code, coupled with comments of different formats, looks like a word: Messy. No matter whether others can understand it or not, as long as they can achieve their own goals.
Because the ASP code is also a script, it is impossible for the customer to see the content. After being more inclusive, some of the business logic in the DLL is, however, I still think that ASP code is the least valuable code. No one can go back and buy it. I can view the source code from other people's websites at any time to get the unique style of stuff that others have worked hard to write. These reasons have led to the development of ASP as a kind of code that is easy to forget and fast to compile. readability and maintainability are also the worst code in various languages.
In fact, ASP code can also be object-oriented and modularized like other languages. It encapsulates many pages into a class and uses different methods in the class to display different pages, in this way, you can encapsulate pages and logic under the same business logic into a class and implement them in different ways. If you have said so much, your thinking may be messy. Let's take a look at the following example:
Copy codeThe Code is as follows: <%
'*************************************** *
'* Class Name: clsWebWorkFlowLog
'* Function: workflow log tracking class
'* History:
'* To: doface
'* Date: 2003/10/24 Ver 1.0
'* Changes:
'* Date:
'*************************************** *
Class clsWebWorkFlowLog
'Define public attributes to store the Connection object
Public ActiveConnection
Private oResponse
'================================================ =
'= Process name: main
'= Parameter:
'= Power: Main 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
'= Parameter:
'= Function: displays the list.
'= Return value:
'================================================ =
Sub list ()
Dim oRs
Set oRs = ActiveConnection.exe cute ("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"> <font color =" # FF0000 "> <B> to-do list: </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. asp? Act = view & tab_id = <%= oRs ("tab_id") %> & id = <%= oRs ("rec_id") %> "> </a> <a href =" javascript: newin ('wfimage. asp? Act = list & id = <%= oRs ("wf_id") %> & bz = 1 & step_id = <%= next_id %> ', true, false, true); "> </a> </p> </td> <%
End if
%> </Tr> <%
ORs. movenext
Loop
%> </Table>
</Center>
<%
End sub
End class
'*************************************** *
'* Class ends
'*************************************** *
'*************************************** *
'Asp page starts
'*************************************** *
'Output standard HTML Headers
GlbFunc. writeHEAD
Dim oWebWorkFlowLog
Set oWebWorkFlowLog = new clsWebWorkFlowLog
Set oWebWorkFlowLog. ActiveConnection = glbFunc. getADOConnection
OWebWorkFlowLog. main
GlbFunc. writeTail ()
%>
You can add more methods so that this class can complete the functions of multiple previous ASP files. During access, you can add parameters (which function to access) after. ASP to differentiate them.