开发者

vb.net looping through several passed parameters with same name

开发者 https://www.devze.com 2023-04-08 01:29 出处:网络
i am passing paramters from one page to another all witht he same name...how do i look through them? dim sHtmlBody

i am passing paramters from one page to another all witht he same name...how do i look through them?

dim sHtmlBody
sHtmlBody = ""
for i=0 to Request.QueryString("name").Count

sHtmlBody = "<html><body onload=""window.print();"">"
sH开发者_开发百科tmlBody = sHtmlBody & "<body>hello</body>"
sHtmlBody = sHtmlBody & "</head>"

next

context.Response.Write(sHtmlBody)

this is what i am doing and it works. But how do i access the individual name

Dim Name =  Request.QueryString("Name")(i)

does not work


You could try the following.

dim sHtmlBody
sHtmlBody = ""
Dim nameValues As String = Request.Form.GetValues("name")

For Each name As var In nameValues

sHtmlBody = "<html><body onload=""window.print();"">"
sHtmlBody = sHtmlBody & "<body>hello</body>"
sHtmlBody = sHtmlBody & "</head>"

Next

Which means you can do the following.

Dim name = Request.Form.GetValues("name")(1)


Assuming the request looks like this: SomePage.aspx?name=name1&name=name2&name=name3 you could split the Name request parameter by comma:

Dim names = Request.QueryString("Name").Split(",")
For Each name As String In names
    ' do something with each name
Next
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号