title: C# ASPX - Form Submission Query
body: <p>I have a C# aspx form in which I need to input it's data into an SQL database and then return a response saying successful or not. I have no idea how to get the form data that is sent from the Default.aspx page. My basic code structure is below:</p>
  
  <p><strong>Default.aspx</strong>  </p>
  
  <pre><code>&lt;form runat="server" name="aForm" action="Results.aspx" method="post" onsubmit="ValidateForm()"&gt;  
    &lt;input name="firstname" type="text" /&gt;
    &lt;input name="surname" type="text" /&gt;
    &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Results.aspx.cs</strong></p>
  
  <pre><code>public partial class AwardsForm : System.Web.UI.Page {
  
    protected void Page_Load(object sender, EventArgs e) {
  
      if (!this.IsPostBack){
          Response.Redirect("Default.aspx");
      } else (this.IsPostBack) {
          writeResults(FormSubmit()); 
      }
  
      protected boolean FormSubmit() {
        // get form data and insert it into SQL
        // return true/false based on success
      }
  
      protected void writeResults(boolean results) {
        if (results == true) {
          Response.Write ("Success");
        } else {
          Response.Write ("Failed");
        }
      }
  
  }
  </code></pre>