The object of ASP code

Source: Internet
Author: User
Tags html header

Mention ASP Many people think it is a bunch of HTML scripts and are enclosed in <% and%> some of the code and some JavaScript scripts, such as the collection of some code, such code, plus various types of annotations in different formats, looks like a word: chaos. And it doesn't matter if anyone can read it, as long as it is possible to achieve their own purposes, because the ASP code is also a script, to the customer can not be seen in the contents of the content, by more inclusive in the DLL part of the business logic, but still feel that the ASP code is the most worthless code, no one went back to buy, Can be at any time from other people's website to see the form of the source of other people worked hard to write out the unique style of Dongdong. These reasons make the development of ASP as a fast-forgotten and fast code, readability, maintenance is the most bad code in various languages.

In fact, ASP code can also be like other languages of the object-oriented, modularization, a lot of page integration into a class, the use of different methods in the class to display different pages, so you can encapsulate the same business logic of the page and logic into a class, in a different way to implement. Said so much, maybe everyone's ideas are messy, and quickly give you a sample to see:

<%
'****************************************

' * Class Name: Clswebworkflowlog

' * Function: Workflow Log Tracking class

' * History:

' * Made: Doface

' * Date: 2003/10/24 Ver 1.0

' * Change:

' * Date:

'****************************************

Class Clswebworkflowlog

' Define public properties to store connection objects
Public ActiveConnection

Private Oresponse

'========================================
' = Procedure Name: Main
' = parameter:
' = function: Keynote function
' = perform different actions based on different action parameters
' = return value:
'========================================
Sub Main ()
Select Case Request ("act")
Case "List"
List ()
Case Else
List ()
End Select
End Sub

'========================================
' = Procedure Name: List
' = parameter:
' = Feature: Display list screen
' = return value:
'========================================
Sub List ()
Dim oRs
Set oRs = Activeconnection.execute ("SELECT *" (select name from Wf_config where id=w.wf_id) as Wfname from Wf_log W where s Tep_id=1 and User_id= "& Session (" USR ") (" UID ")
' (SELECT * from Wf_log where ID (select MAX (ID), wf_id,tab_id,rec_id from Wf_log Group by wf_id,tab_id,rec_id where Wf_i D= and Tab_id=))
%> <p align= "left" ><font color= "#FF0000" ><b> to be done:</b>< /font></p>
<center>

<table bgcolor= "#FFFFFF" border= "1" bordercolordark= "#ffffff" bordercolorlight= "#c0c0c0" cellspacing= "0" width= " 99% "height=" >
<tr>
&LT;TD bgcolor= "#808080" height= "><font color=" #FFFFFF "> Process name </font></td>
&LT;TD bgcolor= "#808080" height= "><font color=" #FFFFFF "> Applicant </font></td>
&LT;TD bgcolor= "#808080" height= "><font color=" #FFFFFF "> Application time </font></td>
&LT;TD bgcolor= "#808080" height= "><font color=" #FFFFFF "> Completion time </font></td>
&LT;TD bgcolor= "#808080" height= "><font color=" #FFFFFF "> Status </font></td>
&LT;TD bgcolor= "#808080" height= "><font color=" #FFFFFF "> Operation </font></td>
</tr><%
Do as not ors.eof
Dim maxid,next_id
If Glbfunc.getmaxid (oRs ("id"). value,activeconnection,maxid,next_id) Then
%><tr>
&LT;TD bgcolor= "#ffffff" height= "><%=ors" ("Wfname")%></a></td>
&LT;TD bgcolor= "#ffffff" height= "><%=session" ("usr") ("name")%>&nbsp;</td>
&LT;TD bgcolor= "#ffffff" height= "><%=ors" ("Exetime")%>&nbsp;</td>
&LT;TD bgcolor= "#ffffff" height= ">&nbsp;</td>"
&LT;TD bgcolor= "#ffffff" height= "><%=glbfunc.getcurzt" (ORs ("id"). value,activeconnection)%></td>
&LT;TD bgcolor= "#ffffff" height= "><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=" detailed "width=" "height=" "></a>&nbsp;<a href=" javascript: Newin (' Wfimage.asp?act=list&id=<%=ors ("wf_id")%>&bz=1&step_id=<%=next_id%> ', True,false , false,false,true); " ></a>&nbsp;</p></td" ><%
End If
%></tr><%
Ors.movenext
Loop
%></table>

</center>
<%
End Sub
End Class
'****************************************
' * Class end
'****************************************


'****************************************
' ASP page start
'****************************************

' Output standard HTML header
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 functionality of previous ASP files. Visit at the time of the. The ASP then adds a parameter (which function to access) to differentiate.

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.