Domanda

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.

È stato utile?

Soluzione

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).

Altri suggerimenti

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

radio0.Checked;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top