Results 1 to 2 of 2

Thread: retrieving variables from URL

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    50

    retrieving variables from URL

    Hello,

    I need to retrieve some variables from the URL in one of my ASP.NET pages and use it in my VB.NET script. I'm not sure how to do that in VB.NET. Here's the situation:

    One one page (also ASP/VB.NET), I've got a table of clients drawn from a database. The left most column is a link that says "print this client" which goes to a printer friendly page with just that one client's info. This is the page I'm dealing with. The way I have the link setup is as follows:

    Response.Write("<td><a href='printclient.aspx?id=" & id & "' target=_blank>Print this client</a></td>")

    and in printclient.aspx, I have this:

    Dim Query As String = "SELECT * FROM investors WHERE id=" & id & ";"

    But as you can probably guess, this doesn't work. It doesn't recognize id as a declared variable. It is there in the URL, but I need to somehow retrieve it from there.

    PS - I know there's a way to post variables in some kind of array stored on the server that keeps it hidden from the client, but I'm not sure how to utilize this. I am open to suggestion.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: retrieving variables from URL

    this sounds like it is just an ASP.NET application to me unless I am missing something.

    All you would need to do is use the Request.QueryString method to get the variable from the URL
    VB Code:
    1. Dim MyID as String = Request.QueryString("id")
    2. Dim Query As String = "SELECT * FROM investors WHERE id=" & MyID  & ";"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width