System learning of ASP starts with several built-in objects of ASP.
Generally referred to as the five major objects: Request, Response, Server, Session, Application
Let’s take a look at the Request object today.
Of course, what has not been mentioned yet is, what exactly does ASP look like? How do I know it is ASP code when I look at the code?
It's very simple. When you see "<%" and "%>", it means it is ASP, and the ASP source code is between them.
Then why do you need to learn about the object and what is the function of the object?
In fact, these built-in objects that can be used in scripts provided by ASP make it easier for users to collect information sent through browser requests, respond to browsers, and store user information, thus allowing object developers to get rid of a lot of tedious work.
The main function of the Request object is to accept and obtain information submitted or uploaded from the client browser on the server side. The Request object can access all information passed on any HTTP request, including parameters, cookies, etc. passed from the Form form using the POST method or GET method.
1. Request.form("name")
This is a way of acceptance that is often used when accepting information from the previous page. Request is an ASP object, and form is a collection of objects contained in the Request object (this is different from the form form in the HTML page, which is the name of a text box, password box, or hidden domain in the previous page form. And there is another very important point: the method of submitting the Form form on the previous page must be the Post method.
It’s better to do it than say it, look at the following two page programs.
1. test1.html (This page is HTML, mainly providing a platform for inputting information to submit the information to the ASP page below for acceptance processing)
[Ctrl+A All selections are given for copying: you can modify some codes first, and then click Run]
Note that method is post, and the submitted page action is submit1.asp.
2, submit1.asp (ASP page, perform two values of name="yourname" and name="yourpwd" from test1.html)
your name is:<%=request.form("yourname")%><br> your pwd is:<%=request.form("yurpwd")%> |
Through IIS, you will find that the two pages are related: name and pwd entered dynamically in test1.html, and dynamically displayed in submit1.asp.
This is the whole process of receiving, extracting and displaying information.
3. Improved submit1.asp
<% for each i in request.form%> <%=i%>: <%=request.form(i)%> <br> <%next%> |
A for loop statement is used to accept and display all form tag information on the previous page. This results are very quickly when there are many items on the form page.