【问题标题】:how to store query string value in an array using .net如何使用.net将查询字符串值存储在数组中
【发布时间】:2012-08-06 16:55:55
【问题描述】:

我正在使用当前页面 aspx 作为 url.am 在我的页面 url 中传递查询字符串。我的代码用于拆分查询字符串并写入屏幕。我在页面加载方法中编写代码。

my code
------
 Dim strarr() As String
    Dim key
    For Each key In Request.QueryString
        Response.Write(key & ": " & Request.QueryString(key) & "<BR>")

    Next

output
------
http://localhost:54592/vicidial_project/Default.aspx?a=1&b=2(in run time am passing query string to that url)

a:1
b:2

the query string values are displayed in the screen like above.

my question
-----------
i want to store that query string value into an array . am using the code like this

code
-----
 Dim strarr() As String
    Dim key
    For Each key In Request.QueryString
        Response.Write(key & ": " & Request.QueryString(key) & "<BR>")
       strarr = key & ": " & Request.QueryString(key)

    Next

error
-----
 am getting error in this line
 strarr = key & ": " & Request.QueryString(key)

【问题讨论】:

    标签: arrays string vb.net-2010 querystringparameter


    【解决方案1】:

    为什么不将 key 声明为 String?你可以这样做:

    For Each key as String in Request.QueryString
       ...
    Next
    

    【讨论】:

    • 出现错误,例如“类型字符串无法转换为字符串的一维数组
    猜你喜欢
    • 2011-09-03
    • 1970-01-01
    • 2018-12-06
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-02
    相关资源
    最近更新 更多