19 Basic Tips for ASP (2)

Source: Internet
Author: User
Tips for the following example:


<%


Fori=1 to Request.fron ("INPUT1"). Count


Response.Write Request. From ("Input1") (I) & "<br>"


Next


%>


if INPUT1 has two values, it shows


* If the index specified is not used to read which. Available


〈%


for each item request. From ("input"))


repomse.write Item & "<br>"


Next


%>


can also be used for each x in Tewuest. From "repeatedly gets the input values for all fields.


  


<% for each x in request. Form%>


request. From (<%=x%) =<%=request. Form


(x)%> <br>


<% Next%>


  


  


12. How to obtain the client TCP/IP port:


such as: TCP/IP port is <%=request ("Server_port")%>


uses Server_port to receive connection port information for HTTP request


  


  


13. Using Http_accept_language HTTP header information, you can get the user-side language


environment.


The following example to determine the user side of the language environment, give a different page.


<% language=request.servervariables ("Http_accept_language")


if language= "en" then%>


<!--#include file= "english.asp" >


<% Else%>


<!--#include file= "china.asp" >


<% End if%>


  


14. Home Page Retention Term


If the client browser browses this home page for the duration of a home page reservation, the original

The home page content on the
hard drive will be displayed.


Response.expires[=number]


number is the retention period for the Record Data box (PAGE box), in minutes.


or:


Response.expiresabsolute[=[date][time]]


: Set a home page retention period to a certain date.


  


15. Connect to the specified URL address


such as: you want to confirm that the user has seen the index.htm, you can check whether you have seen, such as


is not confirmed, automatically connects to the home page


<%


If not session ("Been_to_home_page") then


Response.Redirect "Index.asp"


End If


%>


  


16. To judge whether to return to this page or to enter
for the first time

<%


if User_has_been_here_before then


Response.Write "<h3 align=center> Welcome back


Again "


Else


Response.Write "welcome!"


End If


%>


  


  


17. Display a picture in a database with a super connection


  


<%


set Conn=server.creatobject ("Adodb.connection")


Conn.Open "Myaddress"


Set Rs=conn.execute ("Select Name,tel,url,image from


myaddress ")


%>


  


<p>


<tabel>


<tr>


<% for i=0 to Rs.fields.count-1%>


<td>


<b>


<%=rs (i). Name%>


</b>


</td>


<% Next%>


</tr>


<% do and not rs.eof%>


<tr>


<% for i=0 to Rs.fields.count-1%>


<td valign =top>


<%


if RS (i) name= "image" then


Response.Write "<img src=" "&rs (i) &" ">"


Else


if RS (i). name= "url" then


Response.Write "<a href=" "&rs (i) &" ">" &rs (i) & "</a>"


Else


Response.Write rs (i)


End If


End If


%>


</td>


<%next%>


</tr>


<% Rs.movenext


Loop


Rs.close


Conn.close


%>


</html>


  


  


18. Using ASP to obtain browser information


<%


set A=server.creatobject ("MSWC. BrowserType ")


msg= "The browser you are using is:" +a.browser+ "version" +a.version


%>


<%=msg%>


  


  


19. How the ASP accesses cookies (using response and request)


is as follows:


Write cookies:


response.cookies ("Coookies name to write")


= "Pending Write Data"


Read cookies:


Read the data =request.cookies ("Cookies name to be read")


  

Note
when
* Write

@ Write cookies to the Response.Cookies program section must be placed in the <html> tag


before. And you can't have any other HTML code


@ Cookies must use expires to set the expiration date, the cookies can really


is written to the client hard disk. such as:


response.cookies ("name to write"). expires= #july 1,1998#


or Response.Cookies ("name"). expires=date+365





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.