C
C#2y ago
Messiah

❔ [RazorPages] Any clues why this Select isn't working?

Index.cshtml.cs
public async Task<IActionResult> OnGet(string qstring)
{
Console.writeline(qstring)
return Page();
}

Index.cshtml
@page "{qstring?}"
<form method="get" asp-page="Index">
<select name="qstring">
<option value="one">one</option>
<option value="two">two</option>
</select>
</form>
Index.cshtml.cs
public async Task<IActionResult> OnGet(string qstring)
{
Console.writeline(qstring)
return Page();
}

Index.cshtml
@page "{qstring?}"
<form method="get" asp-page="Index">
<select name="qstring">
<option value="one">one</option>
<option value="two">two</option>
</select>
</form>
In theory it should print out and refresh the page when I select, but in reality it's not working. What's happening?
5 Replies
Angius
Angius2y ago
I don't see anything that'd send the form
Connor
Connor2y ago
I think what you’re looking for is <select name="qstring" onchange="this.form.submit()">
Messiah
MessiahOP2y ago
I had a sumit button, sorry.
Angius
Angius2y ago
Try adding [FromQuery] attribute to the param
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?