Regular Expression Validator displaying a label
Here's my situation, I have four regular expression validator's that are controlToValidated to 4 different text boxes. When someone puts types in a symbol or invalid character the RegExpVal error message displays a N/A. I also want if 1 or all of the 4 RegExpVal display an error message a label to display called lblMessage. Code is below
which by the way, all the controls are ontop of Formviews!!!, that's the reason for the FindControl method.
{
RegularExpressionValidator revConfig = new RegularExpressionValidator();
revConfig = (RegularExpressionValidator)FormView3.FindControl( "revConfigurationItems");
RegularExpressionValidator revTaskName = new RegularExpressionValidator();
revTaskName = (RegularExpressionValidator)FormView3.FindControl( "revTaskName");
RegularExpressionValidator revDescription = new RegularExpressionValidator();
revDescription = (RegularExpressionValidator)FormView3.FindControl( "revDescription");
RegularExpressionValidator revRiskDescription = new RegularExpressionValidator();
revRiskDescription = (RegularExpressionValidator)FormView3.FindControl( "revRiskDescription");
Label lblMessage = new Label();
lblmessage = (Label)FormView3.FindControl("lblMessage");
if (revConfig.ErrorMessage = true)
{
lblmessage.Visible = true;
}
else if (revTaskName.ErrorMessage = true)
{
lblmessage.Visible = true;
}
else if (revDescription.ErrorMessage = true)
{
lblmessage.Visible = true;
}
else if (revRiskDescription.ErrorMessage = true)
{
lblmessage.Visible = true;
}
else
{
lblmessage.Visible = false;
}
}
I receive a message of cannot convert string to bool and bool to string when I debug or run the page. The text is already inside the label but the label is visible = false;
Any ideas would be helpful and appreciated.
|