How can I retrieve the values of controls in the form that posted?

Posted by Mike at KBS on Stack Overflow See other posts from Stack Overflow or by Mike at KBS
Published on 2010-05-13T07:47:53Z Indexed on 2010/05/13 7:54 UTC
Read the original article Hit count: 208

Filed under:
|
|

I know this has got to be the simplest-sounding question ever asked about ASP.Net but I'm baffled. I have a form wherein my visitor will enter name, address, etc. Then I am POSTing that form via the PostBackUrl property of my Submit button to another page, where the fields are supposed to be all re-formed into new hidden fields, then POSTed again to Paypal.

My problem is I cannot get at the values entered by the visitor in the original page. Any time I put in "runat='server'", ASP.Net completely changes the ID of the control, making it impossible to figure out how to access. In the POSTed form I tried Request.Form["_txtFirstName"] and that turned up null. Then I tried ((TextBox)PreviousPage.FindControl("_txtFirstName")).Text and that was null, too. I've tried variations on those. I cannot figure out how I'm supposed to get at these controls. Why does this stuff need to be so difficult?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about request.form