This is my first question in stackoverflow.com.
I am working on a school project which I have to validate the input from the user. Everytime the page load, it give the server error message. Please see the codes, and the error message after.
<div>
<table>
<td>
<asp:RadioButton ID="RadioButton1" runat="server"></asp:RadioButton>
<asp:RequiredFieldValidator ID="validateCheck" runat="server" ControlToValidate="RadioButton1" ErrorMessage="Please Enter" Display="Dynamic"></asp:RequiredFieldValidator>
</td>
</table>
</div>
Server Error in '/' Application.
Control 'RadioButton1' referenced by the ControlToValidate property of 'validateCheck' cannot be validated.
The RequiredFieldValidator does not validate a RadioButton. However, you can use the RadioButtonList control instead (validated by RequiredFieldValidator).
The asp:RadioButton do not support validation, instead of RadioButton use a RadioButtonList:'
<form id="form1" runat="server">
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="RequiredFieldValidator" ControlToValidate="RadioButtonList1"></asp:RequiredFieldValidator>
</div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
</asp:RadioButtonList>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With