Latest web development tutorials

raccolta ASP QueryString

Richiesta Object Reference Completa Object Request Reference

Querystring raccolta viene utilizzata per recuperare il valore della variabile nella stringa di query HTTP.

stringa di query HTTP è specificato dal valore dopo il punto interrogativo, per esempio, (?):

<a href= "test.html?txt=this è una stringa di query test"> legame con una stringa di query </a>

Il codice precedente genera un file chiamato txt con il valore "questo è un test stringa di query" variabile.

Le stringhe di query vengono generati anche dal modulo di presentazione, o da un utente inserisce una query nella barra degli indirizzi del browser.

NOTA: Se avete bisogno di inviare grandi quantità di dati (più di 100kb), non è possibile utilizzare Request.QueryString.

grammatica

Request.QueryString(variable)[(index)|.Count]

参数 描述
variable 必需。在 HTTP 查询字符串中要取回的变量名称。
index 可选。为一个变量规定多个值之一。从 1 到 Request.QueryString(variable).Count。


Esempi

esempio 1

valori di stringa di query attraversamento di tutte le variabili n:

Abbiamo pensato che questa richiesta viene inviata:

http://www.w3cschool.cc/test/names.html?n=John&n=Susan

Il names.asp contiene il seguente codice:

<%
for i=1 to Request.QueryString("n").Count
Response.Write(Request.QueryString("n")(i) & "<br>")
next
%>

names.asp file mostrerà:

John
Susan

esempio 2

Supponiamo che la stringa viene inviata:

http://www.w3cschool.cc/test/names.html?name=John&age=30

Il codice precedente produce il seguente valore QUERY_STRING:

name=John&age=30

Ora, siamo in grado di utilizzare le informazioni nello script:

Hi, <%=Request.QueryString("name")%>.
Your age is <%= Request.QueryString("age")%>.

uscita:

Hi, John. Your age is 30.

Se non si specifica alcun valore variabile da visualizzare, come questo:

Query string is: <%=Request.QueryString%>

Output sarà simile a questo:

Query string is: name=John&age=30


Richiesta Object Reference Completa Object Request Reference