I need to get the selected value on Change of Item from the DropdownList in ASP.NET Razor Pages. Here is the model class code
public class AddNonRecuringPatientPaymentsModel : PageModel
{
public SelectList InstitutionsOrgCodes { get; set; }
public void OnGet()
{
//Populate Institutions DropDownList
this.InstitutionsOrgCodes = new SelectList(items: spProc.PopulateInstitutionOrgCodes(), dataValueField: "InstIDOrgCode", dataTextField: "InstitutionName");
}
Here is the View code
<select class="form-select" id="ddlInstitution" asp-items="@Model.InstitutionsOrgCodes" asp-for="InstIDOrgCode" placeholder="Institution ID">
<option selected disabled value="">Institution...</option>
</select>
<label for="ddlInstitution">Select Institution</label>
<span asp-validation-for="InstIDOrgCode" class="text-danger"></span>
Every time the value changes I want to get the selected value from the Dropdown list and store it in a text field. How can I achieve this?