Adding FrontEnd validator

WebForms has control validators, you can add a validator to a newly added control.

Let's say you want to add a required validator for a new textbox control.

Add the required validator in the Frontend and set an unique id.


<wm-required-field-validator id="rev1" [model]="model.rev1" class="rev1">

Then, you have to declare the validator in the Backend file.


protected Mobilize.Web.UI.Controls.RequiredFieldValidator rev1 { get; set; }

In the same file you have to initialize and set the necessary properties in the InitializeComponent method

this.rev2 = new Mobilize.Web.UI.Controls.RequiredFieldValidator();
this.rev2.Name = "rev1";
this.rev2.ControlToValidate = "Textbox2";
this.rev2.ErrorMessage = "Validator Error Message";

The ControlToValidate property must be the same as the Control.Name you want to validate. In the previous example we have a textbox with that name.

this.TextBox2.Name = "Textbox2";

After these changes the new validator is ready.

Last updated