views:

44

answers:

1

I have an asp page with an input/text field and an anchor/href that links to an aspx page. What I want is to populate the label control on my aspx page with the value entered in the input/text field. How would I do that?

+4  A: 

There's no immediate way, with a hyperlink, to pick up values from form fields and pass them to the target of the hyperlink. You need to either:

  1. Attach a javascript event handler to the hyperlink, rather than setting the href="" that targets your aspx page and passes the value from the input field in the query string. You can then use Request.QueryString["NameOfValuePassedIn"] in your aspx page to pick up the value and assign it to your label.

    or

  2. Change the <form> element in your asp page so that its action attribute points at the aspx page and then either add a submit button, or change your hyperlink so it again uses javascript, but this time to trigger the form to submit. You can then use Request.Form["NameOfValuePassedIn"] in your aspx page to pick up the value and assign it to your label.

Rob
+1 - pretty much the two options I would suggest.
Oded
+1 for posting directly to the aspx page.
rockinthesixstring