15 very useful examples in programming ASP programming
Enet College
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?
To 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: ">
6. How to determine the IP address of each other
Answer 〈%=request.servervariables ("REMOTE_ADDR")%>
7. How to link to a picture
<% @Languages =vbscript%>
<% response.expires=0
Strimagename= "Graphix/errors/erroriamge.gif"
Response.Redirect (Strimagename)
%>