title: Partial view - avoiding nested forms
body: <p><strong>View</strong></p>
  
  <pre><code>@using (Html.BeginForm())
  {
      ...form elements
      @Html.Action("PartialView")
  }
  </code></pre>
  
  <p><strong>PartialView</strong></p>
  
  <pre><code>if (something) {
      &lt;input type="submit" value="Submit" /&gt;
  } else {
      @using (Html.BeginForm())
      {
          &lt;input type="submit" value="Submit" /&gt;
      }
  </code></pre>
  
  <p>Can anybody suggest a way around the above problem?</p>
  
  <p>If the PartialView if statement returns false, I end up with nested forms. I can move the form close bracket within the partial view to avoid nesting the forms and the page renders correctly but this upsets visual studio because it expects to see the close bracket within the view. Does that matter?</p>
  
  <p>Edit:</p>
  
  <p>Based on Chris's comments, is the below modification a better approach? i.e. One form with two submit buttons that call different code within the same action method?</p>
  
  <p><strong>PartialView</strong></p>
  
  <pre><code>if (something) {
      &lt;input type="submit" name="btn" value="Submit1" /&gt;
  } else {
      &lt;input type="submit" name="btn" value="Submit2" /&gt;
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult Index()
  {
      if (btn == "Submit1") {
          ...do a thing
      } else {
          ...do another thing
      };
  }
  </code></pre>