How to start designing an ASP website
Author:Eve Cole
Update Time:2009-06-25 17:36:26
When starting to design an ASP website, we are faced with a lot of problems. How should we start so that the website design can be fast, good, and debugging, changing, and transplanting easily? Let’s take the guestbook design as an example to talk about the site design.
(1) Site functions
"Whether you sharpen your sword or chop wood," writing down the functions of the site first will be of great help to future work. Now let’s design a guestbook with the following functions:
1. Single user version. There is only one administrator, everyone can leave messages and search messages
2. Record the IP, QQ, avatar, name, homepage, email, message time, and message content of each commenter;
3. There is an administrator reply function. If you have already replied, you can also change the content of the reply. Record the time of response;
4. Record the location of the homepage to quickly return to the homepage.
5. Customized header and footer. Display specific information.
6. Save data to ACCESS database
7. Management functions: Administrator login/reply/delete/change administrator password/change the number of displayed messages/change homepage
(2) Site database
Generally, ASP sites use databases. First, design the database. When using it, you will not query or change the design of the database for a field. Especially for large websites, good database design can affect the operation of the entire website. Now let’s design the guestbook database:
1. Database name: lyb.mdb
2. Table: There are two tables in total
Table 1: admin
Field name | type | length | other | instructions |
admin_user | text | 15 | does not allow null values / primary key | administrator user name |
admin_pass | text | 15 | does not allow null values | administrator password |
admin_http | text | 50 | can be null | home page address |
admin_perpage | number / integer | | decimal is 0 | |
Table 2: main
Field name | type | length | other | instructions |
user_id | automatic numbering | | | |
user_name | text | 15 | is not empty | name |
user_image | text | 30 | is not empty | avatar file name |
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 page |
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 |
The guestbook database is relatively simple. If it is a large website, you need to check it repeatedly after the database is designed. It is best to use naming standards for all field names. After the database design is completed, it is best to print out a list like the one above for convenience.
(3) Site file design
The design of files mainly involves designing how many files there are, what content each file contains, and the relationship between them. Taking the guestbook as an example, the file design is as follows:
1. Inc.asp related functions and constants, including open database function, open table function, word processing function
2. top.htm header information
3. bottom.htm footer information
4. index.asp guestbook main page. Including displaying messages, administrator login, modifying parameters, and replying to messages. Quote inc.asp;
5. main.css css file;
6. tou.htm avatar list file;
7. Image folder, save avatars and other pictures;
(4) Site page design
Page design mainly involves designing the style and layout of the page. This part contains a lot of content. Generally, you first determine the style of the entire page, then design all the illustrations and Flash, then design the CSS, and finally design each page. For pages with repeated content, design individual content first. Only the general design of index.asp is listed here, as follows:
'Quote inc.asp <% 'Processing parameters 'Message subroutine 'Login subroutine 'Reply subroutine 'Delete subroutine 'Modify parameter subroutine 'Exit the login subroutine %> <html> <head> <!-Quote CSS-!> <title>Guestbook</title> <body> 'Quote top.htm 'Display message form 'Show search form 'Show message record 'Quote bottom.htm </body> </html> |
Of course, in the page design stage, you do not need to write subroutines, just do all the display parts well.
(5) Code design of website pages
The main thing is to complete the design of the ASP code. Here we only talk about how to enhance the modifiability and portability of the site. There is only one thing: multi-use components or functions, of course it would be better if they are written as classes. For small sites, you don’t want to use set conn=server.createobject("adodb.connection") in a subroutine of each page. Instead, you write it as a function or subroutine and put it 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&";pid="&pid connect.Open strconn end sub %> |
In this way, when you change the database name or user name and password, you can easily modify it. After a period of accumulation, you will have many such functions, subroutines, or classes. When you build a similar site, just sort out the relevant ones and put them in a file for reference.