Change the selectedIndex of a html element "select" from codebehind C #?

0

I have a HTML "select" element in a form with several options. The list of options I fill from JavaScript when I load the page. I need to change the option chosen from server but when I access the "select" it tells me that it is empty with selectedIndex = 0 and value="". On the other hand, if I access the value with Request.Form ["mySelect"] it returns the chosen value.

In HTML:

<select id="mySelect"  name="mySelect" runat="server"> </select>

In CodeBehind:

mySelect.Value // me devuelve ""
mySelect.SelectedIndex // me devuelve 0

Request.Form["mySelect"] // me devuelve el valor de la opción seleccionada correctamente.
    
asked by Popularfan 09.11.2018 в 15:31
source

0 answers