Link to home
Start Free TrialLog in
Avatar of swathi111
swathi111

asked on

RequiredFieldValidator for an optional field

Hi,

Please find the attached file.

If i select Add New radio button, RadEditor control will be displayed.If I select Link to existing radio button, URL field will be displayed. If user select Add New then RadEditor is a mandatory field. If user select Link to Existing then URL field is the mandatory field. How to check this?

I put 2 RequiredFieldValidator controls and by default i make it enabled = false then on click of submit button i enabled as below but it is not working:

  protected void btnSubmit_Click(object sender, EventArgs arg)
        {
            if (radioAddNew.Checked)
                RequiredFieldValidatorRadEditorContent.Enabled = true;
            else if (radioLinkToExisting.Checked)
                RequiredFieldValidatorURL.Enabled = true;

            if (Page.IsValid)
            {
                  //other code
      }
      }

Any other way to do this?


Thanks,
Requiredfieldvalidator.jpg
ASKER CERTIFIED SOLUTION
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial