|
Author: Jenny Nguyen
|
|
To use the RequiredFieldValidator for radion button in ASP.NET you must use the RadioButtonList control. It is not possible to do it with the normal radion button. 1. First add the RadioButtonList control to your page. 2. Now add the RequireFieldValidator to your page. Make sure you set the ControlToValidate property to the ID of the RadioButtonList. 3. Set all the other proporties of the two control as required. EXAMPLES: <tr> <td> Would you like to continue? <br /> </td> <td class="style1"> <asp:RadioButtonList ID="rdlYesNo" runat="server" RepeatDirection="Horizontal"> <asp:ListItem Text="Yes" Value="Yes"></asp:ListItem> <asp:ListItem Text="No" Value="No"></asp:ListItem> </asp:RadioButtonList> <asp:RequiredFieldValidator ID="rfvrdlYesNo" runat="server" ControlToValidate="rdlYesNo" Display="Dynamic" ErrorMessage="Would you like to continue? is required." ValidationGroup="InflightProfile">*</asp:RequiredFieldValidator> </td> </tr> <tr>
|