Вопрос

I know some will ask why i am not using asp.net html controls and others will say that I should use asp.net controls, but my question is about how to do this using plain old html controls.

If I have the following:

<INPUT runat="server" type="radio" name="radio" id="radio0">Radio Button 0
<br>
<INPUT runat="server" type="radio" name="radio" id="radio1">Radio Button 1

where the user selects one of these radio buttons, so it should be a client side selection. Is it possible for me (asp.net at the server) to determine which radio button has been selected when the user submits the form?

I need the server to be able to determine this, so it can do an action based on the radio button selected.

Это было полезно?

Решение

I don't know asp.net but normally you would add a value to your radio buttons.

<input runat="server" type="radio" name="radio" id="radio0" value="0"> Radio Button 0
<br>
<input runat="server" type="radio" name="radio" id="radio1" value="1"> Radio Button 1

And submitting the form would return the selected radio button value for the name attribute parameter (in this case you named it radio).

Другие советы

You can determine which radio button has been selected server-side using the .Checked property.

radio0.Checked;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top