radiobutton validation

Contributor
12Jun2009,02:53   #1
Carlos's Avatar
Hi! can anyone tell me how can i apply validation that one of the radio button must be selected among three radio buttons.

It is quite easy to handle it through radiobuttonlist but the format appear in list.

Please provide code in C#.

thanx
Go4Expert Founder
12Jun2009,09:41   #2
shabbir's Avatar
If you make one selected then there is no way user can go without making a selection.
Contributor
12Jun2009,15:30   #3
Carlos's Avatar
Yes, but i want that none of them should be selected, and the validation enforce user to select any one by himself.
Go4Expert Founder
12Jun2009,15:41   #4
shabbir's Avatar
Check for the value of them and atleast should be one.
~ Б0ЯИ Τ0 С0δЭ ~
12Jun2009,18:17   #5
SaswatPadhi's Avatar
Like :

Code: C#
bool flag = false;

flag = flag || radiobutton1.Checked;
flag = flag || radiobutton2.Checked;
flag = flag || radiobutton3.Checked;

if( flag )
{
      // continue execution
}
else
{
      // prompt user to select a radiobutton
}

Last edited by SaswatPadhi; 12Jun2009 at 18:21..