Several tips for ASP Web page development process

Source: Internet
Author: User
Tags count empty interface key words readline microsoft frontpage
Process | skills | Web page

  absrtact: This paper introduces several techniques of Web page design with ASP, including the creation and automatic updating of news bar, as well as the creation, use and maintenance of bulletin boards. Indicates a rough way to resolve this type of problem.

Abstract:we introduce several tricks when the using Active Server Pages to design homepages. These include the creation and automatic updating of news columns, as as the the creation, utilization and maintenance of Bulletins. The general solutions of problems are pointed out.

  Key Words: ASP, news bar, bulletin boards

ASP is a technology introduced by Microsoft to replace the Common Gateway Interface, the English full name active Server Pages. It is a Web server-side running environment. The ASP itself contains VBScript and JavaScript engines that allow scripts to be embedded directly in HTML. We are now using the process of ASP several small tips to share with you.

  One, the news bar

Most pages have a news bar to display the topic of the most recent news, and click on this topic to view detailed reports. If you write every day on the page, and then set up the link is too troublesome. How can I make it automatically updated according to the file?

1. Preparatory work:

1 The establishment of a folder, named "News", the assumption is stored in the d:/asp/directory;

2 Write the details of each piece of news to the file, and the name of the file is: X (newstime). htm. where x is the subject of this piece of news, newstime the time of this press release (written in year-month-day order). Why do you write this? Look at the following algorithm thought and the source program to know.

2. Algorithmic thinking: For files in the News folder, sort from large to small according to the time of the press release in their file name (that is, the contents in parentheses). As a result, the latest news is on top, as long as the top file names in the News folder are displayed in the appropriate location on the page, because the name of the file is described in 1, and the latest news is displayed in the news bar.

3. Source program segment (written in VBScript)

<%
Dim FS, F, F1, FC, FileNum
Dim count
Dim i,j,t1,t2
Dim file (100)
Dim mystr (100) ' flag a string of dates in a file
Count=0
Set fs = CreateObject ("Scripting.FileSystemObject")
Set f = fs. GetFolder ("D:/asp/news")
Set FC = F.files
For each F1 in FC
Count=count+1 ' Count of files
File (count) =fs.getbasename (F1) ' tag base name
MYPOS=INSTR (1, file (count), "()") position in the file base name
' The date string in the base name of the file
MyStr (count) = Mid (file (count), MyPos + 1, Len (file (count))-(MyPos + 1))
Next
For I=1 to Count
For J=1 to Count-i
If MyStr (j) <mystr (j+1) Then
T1=file (j)
File (j) =file (j+1
File (j+1) =t1
T2=mystr (j)
MyStr (j) =mystr (j+1)
MyStr (j+1) =t2
End If
Next
Next
J=1
If Count<10 then ' news Bar shows 10 News
Temcount=count
Else
temcount=10
End If
Do While j<=temcount%>
<a href= ". htm" >file:///d:/asp/news/<%=file (j)%>.htm "target=" New_window "><%=file (j)%> </a >
<%
J=j+1
Loop
%>

4. News Bar Content Update:

As long as a good writing habits, so that the name of the news to comply with the 1 requirements, and then put the written documents into the News folder, the press bar will automatically display the latest 10 news.

  Second, bulletin boards

In addition to the news bar, the more commonly used is the bulletin board, bulletin boards are mainly used to show some important notice. Of course, these notices are to be changed frequently. Let the user change the content of the announcement every time to the source program to modify it? Of course not, we must provide a maintenance interface to the user, so that users just enter the notification, the bulletin board on the page will naturally display the content of the notice.

1. The key to addressing this problem is the flexible application of FileSystemObject objects and TextStream objects. In practice, you do not have to set up TextStream objects yourself, because as long as you open the file with the FileSystemObject object, the system automatically establishes the TextStream object. In other words, once the OpenTextFile or CreateTextFile method is invoked, the TextStream object is returned.

2. The relevant documents required are three: update. asp, Bulletin. asp, maintain text. txt, and store them in the D:/asp/maintain directory.

3. Main features and source program segments for three files:

1) update. asp

The main function is to allow users to enter the notice to display, check whether the input is empty, if not empty, then submitted to the "Bulletin. asp" program processing.

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "generator" content= "Microsoft FrontPage 4.0" >
<meta name= "ProgId" content= "FrontPage.Editor.Document" >
<title> Update bulletin Boards content </title>
<body>
<script language=vbscript>
function Datacheck ()
Dim Msg,errflag
Errflag=true
If Len (Trim (maintain.t1.value)) =0 Then
Focusto (0)
Errflag=false
msg= "Please enter the post content you want to submit"
End If
if (Errflag=false) then
MsgBox msg,64, "Oh no!"
Exit function
End If
Datacheck=errflag
Maintain.submit
End Function
Sub Focusto (x)
Document.maintain.elements (x). focus ()
End Sub
</script>
①<form method= "POST" action= "announcement. asp" Name= "maintain" >
<p><input type= "text" name= "T1" size= "" ><input type= "reset" value= "rewrite" name= "B2" >
<input type= "button" value= "Submit" Name= "B1" ></p>
&LT;HR color= #FF99FF size=1>
</form>
</body>

Statement ① the action= "Announcements. asp" section, which indicates that the program to start after form submission is "Post. asp".

2) announcement. asp

The "maintain text. txt" file is read and written through the FileSystemObject object and the Textscream object, making the contents of the top 5 lines of this file a post to be displayed in the bulletin board.

<%
Dim str
Str=request.form (T1)
Dim s (5)
Const FORREADING=1,FORWRITING=2
Dim fso,myfile
Set Fso=server.createobject ("Scripting. FileSystemObject ")
Set Myfile=fso.opentextfile ("Maintain text. txt", ForReading) ' Open file in reading mode
For I=1 to 5 ' bulletin board displays 5 announcements
S (i) =myfile.readline ' read the contents of the file
Next
Myfile.close
Set Myfile=fso.opentextfile ("Maintain text. txt", forwriting,true) ' open file in writing mode
MyFile.WriteLine Str
For I=1 to 4
MyFile.WriteLine s (i) ' writes data back to file
Next
Myfile.close
%>

3) maintain text. txt

This file begins to be empty, and the contents of this file are automatically written after the announcement is entered from the interface displayed by update. ASP.

4. The following code is added to the code snippet for the home page file (usually Default.asp) to display the post location, and the updated announcement can be displayed.

<marquee scrollamount= "2" scrolldelay= "direction=" Up "width=" 223 "height=" "id=" a "> ' bulletin board scroll up and down
<%
Dim S (20)
Dim FSO, MyFile
Set fso = CreateObject ("Scripting.FileSystemObject")
Set MyFile = fso. OpenTextFile ("d:/asp/maintain/maintain text. txt", 1,true)
For I=1 to 5
Readlinetextfile=myfile.readline
S (i) =readlinetextfile
Response.Write "★" & S (i)
Response.Write "<br>"
Next
%>
</marquee>

These two tips, extrapolate, can solve many of these problems. Web design enthusiasts might as well try.



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.