title: Razor Pages POST Multiple Forms w/ Model Binding
body: <p>I have multiple forms on a single razor page that I want to be POSTed after one button is clicked. I tried using a javascript function that would .submit() both forms (put in the onclick= of the button), but only one form's values were actually passed to the OnPost() method serverside. Here's the relevant code from the .cshtml and the .cs files:</p>
  
  <p>StudentMain.cshtml</p>
  
  <pre><code>&lt;!--first form--&gt;
  &lt;form class="login100-form" method="post"&gt;
      &lt;span class="login100-form-title" style="padding-bottom: 38px"&gt;
            Student Information
      &lt;/span&gt;
      &lt;div class="wrap-input100"&gt;
          &lt;input class="input100 has-val" type="text" name="name" value='@ViewData["name"]' readonly/&gt;
          &lt;span class="focus-input100" data-placeholder="Student Name"&gt;&lt;/span&gt;
      &lt;/div&gt;
  
      ...more divs/inputs as above
  
  &lt;/form&gt;
  
  &lt;!--second form--&gt;
  &lt;form class="login100-form" method="post"&gt;
      &lt;div class="wrap-input100"&gt;
          &lt;select class="input100 select" name="eduplan" selectedval='@ViewData["eduplan"]'&gt;
              &lt;option disabled selected value style="display:none"/&gt;
              &lt;option&gt;High School Diploma&lt;/option&gt;
              &lt;option&gt;Technical Training&lt;/option&gt;
              &lt;option&gt;Associate Degree&lt;/option&gt;
              &lt;option&gt;Bachelor's Degree&lt;/option&gt;
              &lt;option&gt;Advanced Degree&lt;/option&gt;
              &lt;option&gt;Military&lt;/option&gt;
              &lt;option&gt;Other&lt;/option&gt;
          &lt;/select&gt;
          &lt;span class="focus-input100" data-placeholder="Education Plan"&gt;&lt;/span&gt;
      &lt;/div&gt;
  
      ...more divs/selects as above
  
      &lt;div class="container-login100-form-btn"&gt;
          &lt;div class="wrap-login100-form-btn"&gt;
          &lt;div class="login100-form-bgbtn"&gt;&lt;/div&gt;
              &lt;button class="login100-form-btn" type="submit"&gt;
                  Save
              &lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>StudentMain.cshtml.cs</p>
  
  <pre><code>public class StudentMain : PageModel
  {
       public void OnPost(string eduplan, string college, string major, string careerpath, string ethnicity, string gender, string ncaa, string firstgen, string onlineinterest)
       {
            Database.SaveStudentData(eduplan, college, major, careerpath, ethnicity, gender, ncaa, firstgen, onlineinterest);
       }
  }
  </code></pre>
  
  <p>So, what's the best way to go about doing this? How can I make sure that the values from both forms are passed to the OnPost() method simultaneously? Do I need to use AJAX in some capacity? Any help is appreciated.</p>