20 very useful examples in ASP programming

Source: Internet
Author: User
Tags servervariables
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= "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
Answer:<% @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" >
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.