title: How to reload/call OnGet or OnPost method on DropDown change in ASP.NET Razor Page
body: <p>I'm using the Asp.Net Core Razor Pages for one of my static website. </p>
  
  <p>I have one drop-down on my page and I bind it using the following code.</p>
  
  <pre><code>[BindProperty]
  public string selectedFilter { get; set; }
  
  public List&lt;SelectListItem&gt; Options { get; set; }
  
  public void OnGet()
  {
      this.Options = new List&lt;SelectListItem&gt; {
                      new SelectListItem { Text = "Test1", Value = "1" },
                      new SelectListItem { Text = "Test2", Value = "2" },
                      new SelectListItem { Text = "Test3", Value = "3" },
                  };
      selectedFilter = "3";
  }
  </code></pre>
  
  <p>In cshtml </p>
  
  <pre><code>&lt;select asp-for="selectedFilter" asp-items="Model.Options"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>Once the page load - The Dropdown is rendered properly </p>
  
  <p>Now, I just wanted to know how to handle the <code>onchange</code> event of Dropdown so it calls the <code>OnGet/OnPost</code> method of Razor page and I can get the value in <code>selectedFilter</code> property. </p>
  
  <p>Basically I am doing the content filtering on change event of Dropdown.</p>
  
  <p>I used the <a href="https://www.learnrazorpages.com/razor-pages/forms/select-lists" rel="noreferrer">https://www.learnrazorpages.com/razor-pages/forms/select-lists</a> as reference.</p>
  
  <p>Thank you in advance. </p>
  
  <hr>
  
  <p>Update (Answer)</p>
  
  <p>I got success by putting the SELECT into FORM element like below. </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form method="post"&gt;
    &lt;!-- Other HTML --&gt;
    &lt;select asp-for="selectedFilter" asp-items="Model.Options" onchange="this.form.submit();"&gt;&lt;/select&gt;
    &lt;!-- Other HTML --&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And added the following OnPost method into CS file. </p>
  
  <pre class="lang-cs prettyprint-override"><code>public void OnPost()
  {
    //Here you will get the selected value into selectedFilter 
  }
  </code></pre>
  
  <p>Thank you everyone for helping me out</p>