title: Populate a textbox based on selected value from dropdown using ASP.NET Core MVC
body: <p>I am using ASP.NET Core 3.1 MVC to create a page with a form. The form has a dropdown and a textbox. The dropdown is populated with values from the database. The textbox will populate with a value from the same table and the dropdown, based on the selected dropdown value. My goal is to call a function from my controller inside of my view, is that possible?</p>
  <p>My cshtml file:</p>
  <pre><code>&lt;form method=&quot;post&quot; asp-controller=&quot;Index&quot; asp-action=&quot;Index&quot; role=&quot;form&quot;&gt;
  &lt;div class=&quot;form-group&quot;&gt;
  &lt;select id=&quot;fileName&quot; asp-items=&quot;@(new SelectList(ViewBag.message, &quot;ID&quot;, &quot;fileName&quot;))&quot; onchange=&quot;getUploadedFile()&quot;&gt;&lt;/select&gt;
  &lt;input /&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>My Model</p>
  <pre><code>public class myFiles
  {
  public int ID {get; set;}
  public string fileName {get; set;}
  public string uploadedFile {get; set;}
  }
  </code></pre>
  <p>My controller has a function named GetUploadedFile() which runs a query to the database that returns the file name based on the ID. I originally thought I could reference the GetUploadedFile through my view(cshtml file) by adding the onchange handler and setting it as onchange=&quot;GetUploadedFile()&quot;. I have also tried to do an ajax call to get the UploadedFile.</p>