15 very useful examples in ASP programming

zhaozj2021-02-08  243

15 very useful examples in ASP program 1. How to use ASP to judge your website's virtual physical path: Using mappath method

The Physical Path To this Virtual Website IS: <% = server.mappath ("/")%> 2. How do I know the browser used by the user? A: a method using the Request object 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 repetitive visits daily Answer: Solution <% StartDate = Datediff ("D", Now, "01/01/1990") if strdate <0 Then StartDate = startdate * -1 avgvpd = INT (Usercnt) / StartDate)%> Display result <% response.write (avgvpd)%> That is it.this page has referenced number november 10,1998 4. How to display random image <% DIM P, PPIC, DPIC PPIC = 12 Randomize P = INT (PPIC * RND) 1) DPIC = "Graphix / Randompics /" & P & ". GIF"%> Show > Preivous Page or with images such as:  < % = Request.ServerVariables (>> How to determine the other party's IP address A: <% = Request.serverVariables ("remote_addr)%> 7. How to link to a pair of images: <% @ Languages ​​= VBScript%> <% response.expires = 0 strimagename = "graphix / errors / errooriamge.gif" response.redirect (strimagename)%>

8. Forced input password dialog box: Put this sentence to the beginning of the page <% response.status = "401 Not Authorized" response.END%> 9. How to transfer variables from one page to another: Hidden Type to transmit variable <% form method = "post" action = "mynextpage.asp"> <% for each item in request.form%> <% script language = 'javascript'> alert ("<% = Yourvar%>") 11. Is there a way to protect your source code, do not give people an answer: You can download a Microsoft's Windows Script Encoder, which can encrypt the ASP script and client JavaScript / VBScript script. . . However, after the client encryption, only IE5 can execute, after the server-side script is encrypted, only Script Engine 5 installed on the server can be executed. 12. How can I send Query String from an ASP file to another? A: The former file adds the following sentence: response.redirect ("second.asp?") 13.Global.asa file always does not work? A: Only the web directory is set to Web Application, Global.asa is only valid, and Global.asa is valid in the root directory of a web application.

转载请注明原文地址:https://www.9cbs.com/read-1819.html

New Post(0)