title: ASP.Net MVC Passing value to controller without dedicated button
body: <p>I'm trying to pass a value from my ViewModel to a postmethod, which takes 2 filters (one for type, one for difficulty) from a select list and the id of the member whose lessons are being filtered. The id of the member has to get passed to the HttpPost method, so that the filterByDifficulty methods know the maximum difficulty the member is allowed to get.  </p>
  
  <p><strong>In short:</strong> 
  My get method creates a viewmodel. I pass the viewmodel to the view, but I can't figure out how to pass a certain property from the viewmodel to the post method, without showing it to the user/creating a seperate button.</p>
  
  <p><strong>Controller</strong><br>
  The id parameter is what I'm stuck at, I'm trying to figure out how I can pass it to this method, through the view.</p>
  
  <pre><code>[HttpPost]
  public IActionResult LessonsForMember(string filter, string filter2, int id)
          {
              Person person = _personRepository.GetBy(id);
              string Difficulty = person.Difficulty.DifficultyString;
                          PersonLessonModel plm = new PersonLessonModel
              {
                  Person = person,
                  Types = _lessonRepository.GetTypesLimitedByDifficultyAsSelectList(Difficulty),
                  Difficulties = _lessonRepository.GetDifficultiesLimitedByDifficultyAsSelectList(Difficulty),
                  Lessons = _lessonRepository.GetFilteredLessons(filter, filter2);
              };
              return View(plm);
           }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <p>I'm trying to get the @Model.Person.PersonId in here somewhere, without showing it to the user. I thought about putting it in the Filter button all the way at the bottom, but this caused an error</p>
  
  <pre><code>@model Taijitan.Models.ViewModels.PersonLessonModel
  
  &lt;a asp-controller="Lesson" asp-action="Index"&gt;Previous&lt;/a&gt;
  &lt;br /&gt;
  &lt;form action="/Lesson/LessonsForMember/" method="post"&gt;
      &lt;div class="form-inline"&gt;
          &lt;select id="Difficulties" name="filter" asp-items="@Model.Difficulties as List&lt;SelectListItem&gt;" class="form-control"&gt;
              &lt;option value=""&gt;-- All Difficulties --&lt;/option&gt;
          &lt;/select&gt;
  
          &lt;select id="Types" name="filter2" asp-items="@Model.Types as List&lt;SelectListItem&gt;" class="form-control"&gt;
              &lt;option value=""&gt;-- All Types --&lt;/option&gt;
          &lt;/select&gt;
          //This causes an error
          &lt;button name="id" value="@Model.Person.PersonId" type="submit"&gt;Filter&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>