Why should I use PropertyProxyValidator? ASP.NET

I understand that PropertyProxyValidator integrates with ASP.NET UI. But he cannot perform client-side validation. How can this be different from tagging in a user interface and filling in server-side errors?

In addition, if I use a block of validation applications, what approaches do you propose for client-side validation if I do not want to duplicate the rules on the server and client side?

+3
source share
2 answers

PropertyProxyValidatorwill not help you with client side validation. I think that the main difference from "throwing a tag into the user interface and filling in errors on the server side" is that it PropertyProxyValidatorallows you to have validation errors next to the checked control.

Using PropertyProxyValidatoris a lot of work. Everything must be connected. A nicer solution is to create a simple extension method and register PropertyProxyValidatorin the code behind. It makes everything a lot easier. Here is an example:

protected override void OnPreInit(EventArgs e)
{
    this.LastNameTextBox.For<Person>().AddValidator(p => p.LastName);
    base.OnPreInit(e);
}

Further information on this approach can be found here .

Of course, in this case it is still server-side, but this solution simplifies the inclusion of client-side validation later, since it centralizes the creation of validators.

Tuzo . VAB, .

+2

, PropertyProxyValidator ASP.NET( ) . Application Validation. (, .:))

VAB, PropertyProxyValidator ASP.NET. , (, ) ASP.NET. , /, . ( ) / ().

VAB , . AJAX " " . , , . , Application Validation, VAB . ( - ?).

+1

Source: https://habr.com/ru/post/1737042/


All Articles