Use JavaScript to help me write a counter _asp base

Source: Internet
Author: User
Can you use JavaScript to write a counter for me? The one with the text, I want to use it in ASP? Please ...
I have written one, is not with the text, who can help me to make up for it?
<%@ Language=jscript%>

<%
Application.Lock ();
Application ("Counter") = parseint (Application ("Counter")) + 1;
Application.UnLock ();

%>
I know I'm going to use <%.
var path = Server.MapPath ("test.txt");
var myfileobject = Server.CreateObject ("Scripting.FileSystemObject");
var mytextfile = myfileobject.createtextfile (path);
Mytextfile.writeline ("");
Mytextfile.close ();
%> These commands, how can you write them specifically?

Copy Code code as follows:

Give you one of the most complete bar:
<script language = "vbscript" runat = "server" >
Sub Application_OnStart
' Take the true path of the count file
Countfile=server.mappath ("Count.txt")
' Create a file system object instance
Set myfso = Server.CreateObject ("Scripting.FileSystemObject")
' If the count file does not exist
If not myfso.fileexists (Countfile) Then
' Create the file and get the TextStream object instance
Set mytextstream = Myfso.createtextfile (Countfile, True)
Application.Lock
Application ("online") = 0
Application ("counter") = 0
Application.UnLock
' Writes the count value to the file
Mytextstream.writeline (CStr (Application ("Counter"))
Else
' Open in read-only mode '
Set mytextstream = Myfso.opentextfile (countfile,1,false)
' Read a line and assign the value to the count variable
Application ("counter") = Mytextstream.readline
End If

Mytextstream.close
Set Myfso = Nothing
End Sub

Sub Session_OnStart
Session.Timeout = 1
Countfile = Server.MapPath ("Count.txt")
Set myfso = Server.CreateObject ("Scripting.FileSystemObject")
Application.Lock
Application ("online") = Application ("online") +1
Application ("counter") = Application ("Counter") +1
Application.UnLock
' Open file as write '
Set mytextstream = Myfso.opentextfile (countfile,2,false)
' Writes the data to the file in a write-line way
Mytextstream.writeline (CStr (Application ("Counter"))
Mytextstream.close
Set Myfso = Nothing
End Sub

Sub Session_OnEnd
Application.Lock
Application ("online") = Application ("online")-1
Application.UnLock
End Sub
</script>

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Counter Example </title>
<body>
<div align= "Center" > You are <font color= "#FF0000" ><%=application ("Counter")%></font> VIP!
</div>
</body>

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.