0

Suppose I have url www.abc.com/orders.aspx?order_id=4321 . So in this page there is one textbox on which page loads it should get values from url where id = 4321.

So I tried this code but it's not working. Please help

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
Imad
  • 7,126
  • 12
  • 55
  • 112
  • Try searching. `HttpUtility.ParseQueryString(queryString)("id")`. – CodeCaster Dec 11 '15 at 10:13
  • Put a break point somewhere and in VS's immediate window, try examining the QueryString like: "?Request.QueryString". It will provide some useful insight. – jrjensen Dec 11 '15 at 17:15

1 Answers1

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

try this..

Change ToString to ToString()

Sudhir Panda
  • 774
  • 1
  • 7
  • 27
  • In vb.net, you don't need () at the end of ToString. Also, the QueryString is a dictionary. So the correct syntax is Request.QueryString("order_id") in this example. You're missing the double-quotes. – jrjensen Dec 11 '15 at 17:13