Send this article to Bluetooth as a reference for beginners. I only talk about my personal views and practices. If there are any differences, please correct me.
When I started designing an ASP site, I faced a lot of problems. What should I do to make the website design fast, good, debugging, modification, and porting convenient? The following uses the design of the message book as an example to describe the design of the site.
(1) Functions of the site
"Do not cut firewood by mistake", first write the site function, it will be of great help to the future work. Design a message book with the following functions:
1. single-user edition. Only one administrator can leave a message and search for a message.
2. Record the IP address, QQ, Avatar, name, home page, email, message time, and message content of each message recipient;
3. The Administrator reply function is available. If you have replied, you can change the content of the reply. Record the reply time;
4. Record the location of the home page to quickly return to the home page.
5. Custom page header and footer. Displays specific information.
6. store data in the Access Database
7. management functions: Administrator Logon/reply/delete/change administrator password/change displayed messages/change Homepage
(2) Site Database
Generally, databases are used for ASP sites. First, the database is designed. during use, the database design is not queried or changed for a field. Especially for large websites, a good database design can affect the operation of the entire website. Now let's design the message Book database:
1. Database Name: lyb. MDB
2. Table: There are two tables in total
Table 1: Admin
Other description of field name type Length
Admin_user text 15 does not allow null values/primary key administrator username
Admin_pass text 15 does not allow null administrator password
Admin_http 50 can be a null home address
Admin_perpage number/Integer decimal number is 0
Table 2: Main
Other description of field name type Length
User_id automatic ID
User_name text 15 not empty name
User_image text 30 is not an empty Avatar file name
User_ip text 15 not empty IP Address
User_oicq text 10 can be a blank QQ number
User_http text 50 can be empty home page
User_email 50 text can be empty email
User_time date long date message time
User_ly text 255 is not empty
User_replay yes/no whether to reply
User_rply text 255 can be empty reply content
User_rptime
The message Book database is relatively simple. If it is a large website, it should be checked repeatedly after the database is designed. It is best to use the Naming Standard for all field names. After the database design is complete, it is best to print a list like above for ease of use.
(3) website file Design
The file design mainly refers to the number of files, the content contained in each file, and the relationship between them. Take the message book as an example. The file is designed as follows:
1. Functions and constants related to Inc. asp, including opening database functions, opening table functions, and text processing functions
2、top.htm page header information
3366bottom.htm footer information
4. index. asp message home page. This includes displaying messages, logging on as an administrator, modifying parameters, and replying to messages. Reference Inc. asp;
52.16main.css file;
62.16tou.htm Avatar list file;
7. The image folder stores the Avatar and other images;
(4) website page design
Page design mainly designs the style and layout of pages. This part contains a lot of content. Generally, the style of the whole page is located first, then the illustrations and Flash are designed, CSS is designed, and each page is designed. For repeated content on the page, design a single content first. The general design of index. asp is listed here, as follows:
'Reference Inc. asp
<%
'Processing Parameters
'Message subroutine
'Logon subroutine
'Reply subroutine
'Delete subprograms
'Modify the parameter subroutine
'Exit the logon subroutine
%>
<HTML>
<Head>
<! -Reference CSS-!>
<Title> message book </title>
<Body>
'Reference top.htm
'Display message form
'Display search forms
'Display message records
'Reference bottom.htm
</Body>
</Html>
Of course, in the page design stage, do not write subprograms, as long as you do all the displayed parts.
(5) website page code design
It mainly completes ASP code design. Here we will only talk about how to enhance the site's maintainability and portability. Only one point: use multiple components or functions. Of course, it would be better to write a class. For small sites, you do not want a subroutine on each page to use set conn = server. createobject ("ADODB. connection "), but to write it as a function or subroutine, put in the page, such:
<%
Databasename = "lyb. mdb"
Uid = ""
PID = ""
Sub opendb (CONNECT)
Set connect = server. Createobject ("ADODB. Connection ")
Connect. connectionstring = "driver = {Microsoft Access Driver (*. mdb)}; DBQ = "&_
Server. mappath (databasename) & "; uid =" & uid & "; pid =" & pid
Connect. Open strconn
End sub
%>
In this way, you can easily change the database name, user name, and password. After a period of accumulation, you will have many such functions, subprograms, or classes. When you do a similar website, you just need to sort out the relevant information and reference it in a file.