How to add validation in custom control?

  • 25 October 2017
  • 3 replies
  • 9 views

Badge +1

I created a control LookupListItemPicker, who inherited from EntityEditorWithPicker. Next, I created a custom control LookupControl, who inherited from BaseBindableFormControl. Next, try to add validation of input values in a lookup field. How can I do it?


3 replies

Badge +3

validation for what?  Number?  Text?  the value itself?

Can you use a hidden field computed from the field you are wanting to validate and validate it?

Badge +1

I'm trying to make a control array lookup values from a list using the Sharepoint class EntityEditorWithPicker. If I make this control and use in Sharepoint, it works correctly, once I transfer the code to the control Nintex, the validation is not working. Below is an example in which I record the CustomValidation:

 protected override void CreateValidationControls()
{
if (this.LookupProperties.IsRequired)
{
RequiredFieldValidator requiredFieldValidator = new RequiredFieldValidator();
requiredFieldValidator.ID = "requiredFieldValidator";
requiredFieldValidator.ControlToValidate = this.AssociatedControlForLabel.UniqueID;
requiredFieldValidator.ErrorMessage = string.IsNullOrEmpty(this.LookupProperties.RequiredErrorMessage) ? string.Empty : this.LookupProperties.RequiredErrorMessage;
this.RequiredFieldValidator = (BaseValidator)requiredFieldValidator;
this.ApplyCommonValidatorSettings(this.RequiredFieldValidator);
this._lookupControl.Controls.Add((Control)this.RequiredFieldValidator); 

This approach does not work, because the engine ASP.NET can't find the control for which to make the validation. I don't know what I'm doing wrong.

Sorry for my English.

Badge +3

...way beyond me, sorry can't help!!

Reply