Program
1. How to use ASP to determine the virtual physical path of your website
Answer: Using the MapPath method
< P align=center > < font size=4 face=arial > < b >
The physical path to this virtual website is:
</b > </font >
< font color= #FF0000 size=6 face=arial >
<%= Server.MapPath (\)% >
</font > </p >
2. How do I know the browser used by the user?
Answer: Use the Request object method
Strbrowser=request.servervariables (Http_user_agent)
If Instr (Strbrowser,msie) < > 0 Then
Response.Redirect (formsieonly.htm)
Else
Response.Redirect (forall.htm)
End If
3. How to calculate the average number of repeated visits per day
Answer: the solution
<% Startdate=datediff (d,now,01/01/1990)
If strdate < 0 then startdate=startdate*-1
Avgvpd=int ((usercnt)/startdate)% >
Show results
<% Response.Write (AVGVPD)% >
This is It.this page have been viewed since November 10,1998
4. How to display random images
<% Dim P,ppic,dpic
Ppic=12
Randomize
P=int ((ppic*rnd) +1)
Dpic=graphix/randompics/&p&.gif
% >
Show
< img src= <%=dpic% > >
5. How to get back to the previous page
Answer: < a href= <%=request.servervariables (http_referer)% > >preivous page </a >
Or with pictures such as: < IMG src=http://www.webjx.com/htmldata/2005-03-19/arrowback.gif alt= <%=request.servervariables (HTTP_ REFERER)% > >
6. How to determine the IP address of each other
Answer: <%=request.servervariables (REMOTE_ADDR)% >
7. How to link to a picture
For:
<% @Languages =vbs Cript% >
<% response.expires=0
Strimagename=graphix/errors/erroriamge.gif
Response.Redirect (Strimagename)
% >
8. Forced Enter Password dialog box
A: Put this sentence on the beginning of the page
<% response.status=401 not Authorized
Response.End
% >
9. How to pass variables from one page to another
A: Use the HIDDEN type to pass variables
<% form Method=post action=mynextpage.asp >
<% for per item in request.form% >
< input namee= <%=item% > Type=hidden
Value= <%=server. HTMLEncode (Request.Form (item)% > >
<% next% >
</form >
10. Why I use MsgBox in the ASP program, the program error said no permissions
A: Because the ASP is the server running, if you can display a dialog box on the server, then you have to wait for someone to confirm, your program can continue to execute, and the general server will not be guarded, so Microsoft had to ban this function, and told you in random (:) OH) No permissions. However, ASP and client-side scripting can be combined to display a dialog box, as follows:
<% yourvar= Test dialog box% >
<% s Cript language= ' Javas cript ' >
Alert (<%=yourvar% >)
</script >