In the beginning of the design of an ASP site, faced with a lot of problems, in the end to how to start to make the site design fast, good, and debugging, change, transplant and convenient? Following the design of the message book as an example, talk about the design of the site.
(i) the function of the site
"Maito", first write the function of the site, for the future work has a lot of help. Now to design a message book, the function is as follows:
1, single user version. Only one administrator, everyone can leave a message, you can search the message
2, record the ip,qq of each message, avatar, name, homepage, email, message time, message content;
3, have the administrator reply function. If you have already replied, you can also change the contents of the reply. Record the time of reply;
4, record the location of the homepage, in order to quickly return to the home page.
5, custom headers and footers. Displays the specific information.
6. Save data to an Access database
7, management functions: admin login/reply/delete/change admin password/change the number of messages displayed/change the home page
(ii) Site database
General ASP site to use the database, the first design database, in use will not be for a field to query or change the design of the database. Especially for large Web sites, good database design can affect the entire site's operation. Now let's design the database of the message book:
1, database name: Lyb.mdb
2, table: A total of two tables
Table One: admin
Field name |
Type |
Length |
Other |
Description |
Admin_user |
Text |
15 |
Null value/PRIMARY key not allowed |
Administrator user Name |
Admin_pass |
Text |
15 |
Null value not allowed |
Administrator password |
Admin_http |
Text |
50 |
Can be a null value |
Home Address |
Admin_perpage |
Digital/integral type |
|
Decimal number is 0 |
|
Table II: Main
Field name |
Type |
Length |
Other |
Description |
user_id |
Automatic numbering |
|
|
|
User_name |
Text |
15 |
is not empty |
Name |
User_image |
Text |
30 |
is not empty |
Avatar filename |
User_ip |
Text |
15 |
is not empty |
IP Address |
User_oicq |
Text |
10 |
Can be empty |
QQ number |
User_http |
Text |
50 |
Can be empty |
Home |
User_email |
Text |
50 |
Can be empty |
Email |
User_time |
Date |
Long Date |
|
Message time |
User_ly |
Text |
255 |
is not empty |
Message content |
User_replay |
Yes/No |
|
|
Whether to reply |
User_rply |
Text |
255 |
Can be empty |
Reply content |
User_rptime |
Date |
|
Long Date |
Reply time |
Message the database is relatively simple, if it is a large site, in the database design after repeated inspection. All field names are best to use the naming standard, after the database design is completed, it is best to print out a list like the above to facilitate the use.
(iii) document design of the site
The design of a file is primarily about how many files are designed, what each file contains, and how it is related. Take the message as an example, the document is designed as follows:
1, inc.asp related functions and constants, including open database functions, open Table functions, word processing functions
2, top.htm page header information
3, bottom.htm footer information
4, index.asp Guestbook this homepage. including display message, admin login, modify parameters, reply message. Quoting inc.asp;
5, main.css css file;
6, tou.htm avatar list file;
7, image folder, save Avatar and other pictures;
(iv) page design of the site
Page design is mainly designed to design the style and layout of the page. This part of the content is more, usually first positioning the entire page style, and then design all the illustrations and Flash, and then design CSS, and finally design each page. For pages with duplicate content, first design a single content. The general design of Index.asp is listed here as follows:
' Reference inc.asp
<%
' Processing parameters
' Message subroutine
' Login subroutine
' Reply subroutine
' Remove sub-program
' Modify the Parameter subroutine
' Exit Login subroutine
%>
Message Book
' Reference top.htm
' Show the Message form
' Show Search Form
' Show Message Records
' Reference bottom.htm
of course, in the page design phase, and do not write subroutines, as long as the display of the parts to do the right
(v) station page code design
The main is to complete the design of ASP code. Here just talk about how to make the site modifiable and portable to strengthen. There is only one point: multiple components or functions, of course, if you write the class is better. For small sites, do not want to go to each page of a subroutine to use set Conn=server.createobject ("Adodb.connection"), but to write it as a function or subroutine, placed in the page, such as:
<%
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& ";p id=" &pid
Connect. Open strconn
End Sub
%>
In this way, when you change the database name or username and password, it is convenient to change. After a period of accumulation, you will have a lot of such functions or subroutines, or classes, and then do similar sites, as long as the relevant to put in a file in a reference to the good.