문제

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