Custom validator error: PropertiesValid throws object reference
-
Hello! I´ve made a customError-class inheriting from BaseValidator which I use to add error to Page.Validators from code-behind.
public class CustomError : BaseValidator
At first I inherited fromIValidator
, but I had to be able to setValidationGroup
and so I switched toBaseValidator
. Problem is now the PropertiesValid-property of my class always throws an object reference-error. I´m giving ControlToValidate a correct value, so thats not whats causing this. Does anyone have an idea why this error occurs and how I prevent it? The error looks like this:[NullReferenceException: Objectreference has not been set to an instance of an object.]
[NullReferenceException: Objectreference has not been set to an instance of an object.]
System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +23
System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +37
System.Web.UI.WebControls.BaseValidator.Validate() +58 -
Hello! I´ve made a customError-class inheriting from BaseValidator which I use to add error to Page.Validators from code-behind.
public class CustomError : BaseValidator
At first I inherited fromIValidator
, but I had to be able to setValidationGroup
and so I switched toBaseValidator
. Problem is now the PropertiesValid-property of my class always throws an object reference-error. I´m giving ControlToValidate a correct value, so thats not whats causing this. Does anyone have an idea why this error occurs and how I prevent it? The error looks like this:[NullReferenceException: Objectreference has not been set to an instance of an object.]
[NullReferenceException: Objectreference has not been set to an instance of an object.]
System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +23
System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +37
System.Web.UI.WebControls.BaseValidator.Validate() +58