I am writing a webpart for MOSS 2007. I need to check the text field in this web part or use the required field validation module.
I create the required field validator as follows:
vldProjectError = new RequiredFieldValidator();
vldProjectError.ForeColor = Color.Red;
vldProjectError.ErrorMessage = Resources.LABEL_PROJECT_ERROR;
vldProjectError.ControlToValidate = txtProjectName.ClientID;
vldProjectError.Display = ValidatorDisplay.Dynamic;
this.Controls.Add(vldProjectError);
The above code snippet is in the override of CreateChildControls (). When I open this web page page, I get a general error message in SharePoint. I can not catch the error by debugging.
I noticed that an exception is thrown after CreateChildControls () and before the Render () method, since the debugger never introduces the Render () method
Any idea on using validators on sharepoint websites? Is there something I can't see?