This is a popular question among ASP.NET beginners, because this is done fairly different with .NET. While in PHP you would use $HTTP_POST_VARS[‘field1’] and
$HTTP_GET_VARS[‘field1’] to get the value passed from a form (either using POST or
GET method), in ASP.NET there is a big difference.
First, if you pass the value using the GET method (passed as parameters in the URL), you can retrieve those values similar to how you would done it in PHP:
However, when submitting large forms or forms containing sensitive information such as passwords, you will want to use the POST method. Retrieving values passed by using the POST method is nothing like retrieving them using the GET method – you simply access the form elements like you would in any Windows application. Remember, for this to work you need to use .NET controls such as TextBox and Button, and not HTML controls.
|// If the form was submitted|
string FName = txtFName.Text;
As you can see in the above example, to get a value of an element in a submitted form, you simply access that element’s property. But you first check if IsPostBack is true – if the form was submitted.