简体   繁体   中英

Disable textbox required field validator control

I want to disable the requiredfield validator control for the textbox based on some condition of a variable:

if(var==null)
{
    //Activate it
}
else
{
    //disable it
}

What code do I need here?

if(var == null)
{
  requirefieldvalidator1.Enabled = true;
}
else
{
  requirefieldvalidator1.Enabled = false;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM