I am new to ASP.NET and C# and I'm trying to create a forum. I have a HTML select on my .aspx file and a HTML button, and inside .aspx.cs file I want to get that HTML select value when the button is pressed, but it always gives me the "default" value, not the one actually selected.
This is in my .aspx file:
<select id="sortBySelect" runat="server">
<option value="default">Default</option>
<option value="username">Username</option>
<option value="date">Data</option>
</select>
<button id="sortByButton" runat="server" onserverclick="sortBy">Sort</button>
And inside my .aspx.cs file I have this:
public void sortBy(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine(sortBySelect.Value);
}
I also can't use asp dropdownlist/asp button because it says that it must stay inside a form tag with "runat="server"", but I already have a form tag on my .aspx file, and if I add another one it says that I can't have 2 form tags with "runat="server"".
How can I take the actually selected value of that HTML select?