Click here to Skip to main content
15,798,592 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to validate radio button list by giving message(pls choose any one)if i am not choose any values.

How can i done this?

can any one give example?

Try this code:

<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
        ErrorMessage="Please Choose any value from the list"
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <br />
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
Share this answer
Haven't tried using RequiredFieldValidator on RadioButtonList as what Solution1 stated, but for a single TextBox validation, I am sure that will do it. So, I will show you the server-side validation for that:

foreach(ListItem item in RadioButtonList1.Items)
   if(item.Selected == false)
      lblValidator.Text = "Please choose an item!";

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900