Results 1 to 5 of 5

Thread: passing values via URL

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2003
    Location
    Eire
    Posts
    18

    passing values via URL

    Hey,

    Just a wee Q...I am trying to pass the value from my textbox via a URL and am unsure how to get this value.
    My link reads:

    Code:
    <a href="AddSequence.aspx?RepNo=<%#txtRepNo.Text%>" style="COLOR: #0000ff">Add Sequence to this Rep</a>
    but no luck! How can I pass this value?

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

    Re: passing values via URL

    Originally posted by kto
    Hey,

    Just a wee Q...I am trying to pass the value from my textbox via a URL and am unsure how to get this value.
    My link reads:

    Code:
    <a href="AddSequence.aspx?RepNo=<%#txtRepNo.Text%>" style="COLOR: #0000ff">Add Sequence to this Rep</a>
    but no luck! How can I pass this value?
    Now, I am assuming you are using asp.net. So you just use a namevaluecollection object. The namevaluecollection is in the System.Collections.Specialized namespace:

    Dim col As NameValueCollection = Request.QueryString

    Dim RepNo As String = col.Get("RepNo").ToString()

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2003
    Location
    Eire
    Posts
    18
    Fraid I'm using VB.NET so I can't utilise the NameValueCollection.
    Ordinarily the user clicks on the record from within a datagrid so it is easy to pass the RepNo value to the receiving page (AddSequence), however, the page I am trying to get the textbox value from is on a simple form (just used to display the actual record) and I don't really want to change how the page retrieves the RepNo value (i.e. Request.QueryString()).
    There must be a way to get that value when the user clicks on the link and send it along with my URL, no?!

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2003
    Location
    Eire
    Posts
    18

    Resolved

    for any of you crazy cats who are looking to pass values via URL I found the simple solution by declaring a session variable in my VB e.g.

    Code:
    Session("repno") = RepNo
    and then accessing that session variable from my HTML like so...

    Code:
    <a href="AddSequence.aspx?RepNo=<%=session("repno")%>" style="COLOR: #0000ff">Add Sequence to this Rep</a>
    ahoy!

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

    Re: Resolved

    Originally posted by kto
    for any of you crazy cats who are looking to pass values via URL I found the simple solution by declaring a session variable in my VB e.g.

    Code:
    Session("repno") = RepNo
    and then accessing that session variable from my HTML like so...

    Code:
    <a href="AddSequence.aspx?RepNo=<%=session("repno")%>" style="COLOR: #0000ff">Add Sequence to this Rep</a>
    ahoy!
    Be careful though. I think if the session variable doesn't exist yet, and you try to use it, it will through an error. The book I have says to check for a null value first. It is in C# though, don't know how VB.Net handles it.

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