Request.Querystring(variablevalue)可能吗? [英] Request.Querystring(variablevalue) possible?
问题描述
我正在创建一个使用request.querystring在页面之间传输变量的应用程序.但是,目前我正在根据数组在URL中动态设置变量名,并且我想(基本上)使用同一数组在另一页上检索这些值.因此,我想到了一个简单的解决方案:
I'm creating an application which uses request.querystring to transfer variables between pages. However at the moment I am setting variable names in the URL dynamically in accordance with an array and I want to retrieve these values on another page using (essentially) the same array. So I came up with what I thought would be the simple solution:
For Each x In AnswerIDs
response.write(x)
ctest = Request.Querystring(x)
response.write(ctest)
Next
但是,这似乎不起作用,因为您似乎无法将Request.Querystring()
与变量一起用作参数.有人知道我该怎么做吗?
However this doesn't seem to work as it looks like you can't use Request.Querystring()
with a variable as it's parameter. Has anyone got any idea how I could do this?
这是查询字符串:
QuizMark.asp?11 = 1& 12 = 1
QuizMark.asp?11=1&12=1
在这种情况下,AnswerID由"11"和"12",因此在我的循环中,我希望它写"1"& "1".
In this case AnswerIDs consists of "11" & "12" so in my loop I want it to write "1" & "1".
推荐答案
您可以像这样遍历查询字符串:
You can loop through the querystring like this:
For Each Item in Request.QueryString
Response.Write Item & ": " & Request.QueryString(Item) & "<br/>"
Next
Item包含querystring参数的名称,使用Request.Querystring(Item)可以检索参数的值.
Item contains the name of the querystring parameter, with Request.Querystring(Item) you retrieve the value of the parameter.
这篇关于Request.Querystring(variablevalue)可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!