将URL参数传输到vb.net中的文本框

时间:2015-12-11 10:10:14

标签: asp.net vb.net parsing

假设我有网址www.abc.com/orders.aspx?order_id=4321。所以在这个页面中有一个textbox加载它应该从url获取值,其中id = 4321。

所以我尝试了这段代码,但它没有用。请帮忙

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Request.QueryString.HasKeys Then
            Dim user As String = Request.QueryString(0).ToString
            trackInput.Text = user
        End If
    End Sub

1 个答案:

答案 0 :(得分:0)

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    If Request.QueryString.HasKeys Then
         Dim user As String = Request.QueryString(order_id).ToString()
         trackInput.Text = user
    End If
End Sub

试试这个..

将ToString更改为ToString()