title: Detect which form has been submitted in C#/ASP.NET
body: <p>I have two forms on the same webpage and I would like to detect which one was submitted upon a post event and show a different message dependant on the submitted form.</p>
  
  <p>I have seen a few examples where people have detected this based on which submit button was clicked, but in my case the form could be submitted by simply pressing enter. Is it possible to detect which form was submitted based on the form name/id? If this can not be done, what would be the best approach for this?</p>
  
  <p>Here is my code in it's simplest form, I think the syntax I've used is for when using submit buttons, but I included it just incase I was wrong:</p>
  
  <pre><code>&lt;form method="post" name="form1" id="form1"&gt;
      &lt;input type="text" name="textbox1" /&gt;
  &lt;/form&gt;
  
  &lt;form method="post" name="form2" id="form2"&gt;
      &lt;input type="text" name="textbox2"  /&gt;
  &lt;/form&gt;
  
  if(IsPost){
      if(Request["submit"] == "form1"){
          &lt;p&gt;Form 1 was submitted&lt;/p&gt;
      }else if(Request["submit"] == "form2"){
          &lt;p&gt;Form 2 was submitted&lt;/p&gt;
      }
  }
  </code></pre>