in C#

  • Thread starter Thread starter vinnie
  • Start date Start date
V

vinnie

i have a radiobutton list, and one label with a textbox. Beside the
Texbox i have inserted a fieldvalidator: now, i was wondering if the
code that follows is correct, and if it does, where i should put it.
What i want to do is this: if is selected YES on the RadioButton,
than Fieldvalidator should be Enabled (it is disabled by default).

so here is the code that i have written:

if (RadioButtonListContact.Cheked == "YES")
{
FieldValidatorName.Enabled = true;
}

The fact now is that i don't now where to insert this code, 'cause i
wish the system to activate the FieldValidatorName immediately after
the user has selected the YES option in the RadioButton list.

Thanks
 
vinnie said:
i have a radiobutton list, and one label with a textbox. Beside the
Texbox i have inserted a fieldvalidator: now, i was wondering if the
code that follows is correct, and if it does, where i should put it.
What i want to do is this: if is selected YES on the RadioButton,
than Fieldvalidator should be Enabled (it is disabled by default).

so here is the code that i have written:

if (RadioButtonListContact.Cheked == "YES")
{
FieldValidatorName.Enabled = true;
}

The fact now is that i don't now where to insert this code, 'cause i
wish the system to activate the FieldValidatorName immediately after
the user has selected the YES option in the RadioButton list.

Thanks
You can put this in the checked changed event of your radio button as below

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked) {
MessageBox.Show("Radio button checked changed");
}
}
 
From the error, it appears your object is a radiobuttonlist, not a
radiobutton. Radiobutton supports checked, but not the list, and a
radiobutton.checked returns true or false.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top