Override ScriptControl or BaseValidator for ASP.NET asynchronous control?

I plan to develop an ASP.NET server control to provide asynchronous verification of username availability for new user registrations. The control allows the developer to point it to the "username" text box and it will indicate whether the username is available. Like this example , but without the clumsy UpdatePanel.

One design decision that gives me headaches is to inherit from ScriptControl or BaseValidator .

By implementing it as a ScriptControl , I can simplify the work with the client part and easily localize it using resx.

However, I want to make sure that the validator is working correctly with respect to Page.IsValid. The only way I know this is to override BaseValidator and implement EvaluateIsValid() .

So my question is: how would you suggest structuring this control? Does BaseValidator inherit the best (only) way to get the validator part correctly, or can I do it in some other way?

+4
source share
1 answer

You should be able to do this if you are implementing the IScriptControl interface as well as deriving from BaseValidator:

 public class YourControl : IScriptControl, BaseValidator 

To implement the IScriptControl interface, your control must also have GetScriptReferences and GetScriptDescriptors methods.

+4
source

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


All Articles