<form id="form-element" method="post">
<ejs-dropdownlist id="ddAccessType" width="200" name="AccessType" dataSource="Model.AccessTypes" value="Model.AccessType" placeholder="Select Access Type" popupHeight="220px">
</ejs-dropdownlist>
<div class="form-group">
<div class="col-md-10">
<button type="submit" class="e-control e-btn">Submit</button>
</div>
</div>
</form> |
public class IndexModel : PageModel
{
public string AccessType { get; set; }
public string[] AccessTypes { get; set; }
public void OnGet()
{
AccessTypes = new ListItems().getListItems();
AccessType = "TSAdmin";
}
[HttpPost]
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
AccessTypes = new ListItems().getListItems();
AccessType = Request.Form["AccessType"];
return Page();
}
}
public class DataModel
{
public string AccessType { get; set; }
public string[] AccessTypes { get; set; }
} |