I'm working on a project in which I'm using asp: PlaceHolder and this tag contains a radiobuttonlist , but this radiobuttonlist is not working from HTML but rather what handling from the C #.
The question I have is: Is it possible to access the raddiobuttonlist through JavaScript? If so, how can I do it?
This is my code:
HTML
<asp:PlaceHolder runat="server" ID="phdejemplo"></asp:PlaceHolder>
C #
private void RadioButtonEjemplo(Pregunta pregunta, bool esVisible)
{
var rblRespuestasEjemplo = new RadioButtonList();
rblRespuestasEjemplo.ID = "rblPregunta" + pregunta.PreguntaId;
rblRespuestasEjemplo.Visible = esVisible;
rblRespuestasEjemplo.RepeatDirection = pregunta.ModoVisualizacion ? RepeatDirection.Vertical : RepeatDirection.Horizontal;
rblRespuestasEjemplo.AutoPostBack = true;
rblRespuestasEjemplo.SelectedIndexChanged += (sender, e) => rblRespuestasEjemplo_SelectedIndexChanged(sender, e, pregunta.PreguntaId);
phdejemplo.Controls.Add(rblRespuestasEjemplo);
}
private void rblRespuestasEjemplo_SelectedIndexChanged(object sender, EventArgs e, int preguntaId)
{
RadioButtonList radio = (RadioButtonList)sender;
var respuestaSeleccionadaId = Convert.ToInt32(radio.SelectedValue);
}
What I want to do with the JavaScript is to know if a radiobutton was selected.
Thank you in advance.