question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValidatorCalloutExtender with CustomValidator causes an error if the httpRuntime setting is equal to 4.5

See original GitHub issue

We have set the following for all pages based on suggestions given in another reported issue so that things work well with jQuery: Page.UnobtrusiveValidationMode = UnobtrusiveValidationMode.WebForms;

I’m getting the following error when pairing a ValidatorCalloutExtender with a CustomValidator: Uncaught Sys.ArgumentUndefinedException: Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: id

Upon further tracing through the JavaScript I’ve found that the following line (112) in ValidatorCallout.js is producing the error: var elementToValidate = this._elementToValidate = $get(elt.controltovalidate);

The problem is that the elt object has all of the expected properties prefixed with data-val- like so: <span id="ctl00_Main_customVal" style="display: none;" data-val-evaluationfunction="CustomValidatorEvaluateIsValid" data-val="true" data-val-display="None" data-val-errormessage="A valid member number must be entered" data-val-controltovalidate="ctl00_Main_textboxStudent" data-val-isvalid="False"></span>

Changing the line to this seems to partially solve the issue: var elementToValidate = this._elementToValidate = $get(elt.controltovalidate != null ? elt.controltovalidate : elt.getAttribute('data-val-controltovalidate'));

And the callout is shown to the user, but shows the wrong message and some events aren’t properly handled. This is because the rest of the properties that define what the callout will be like are not being retrieved/used since they’re all prefixed with data-val. For the moment I’ve been able to work around the issue with this hack in our code:

    $(function () {
        var calloutPrototype = Sys.Extended.UI.ValidatorCalloutBehavior.prototype;
        if (calloutPrototype != null) {
            calloutPrototype.get_element2 = calloutPrototype.get_element;
            calloutPrototype.get_element = function () {
                var elt = this.get_element2();
                var $valctrl = $(elt);
                elt.validateemptytext = $valctrl.data('val-validateemptytext');
                elt.clientvalidationfunction = eval($valctrl.data('val-clientvalidationfunction'));
                elt.evaluationfunction = eval($valctrl.data('val-evaluationfunction'));
                elt.val = $valctrl.data('val');
                elt.display = $valctrl.data('val-display');
                elt.errormessage = $valctrl.data('val-errormessage');
                elt.controltovalidate = $valctrl.data('val-controltovalidate');
                return elt;
            };
        }
    });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidIQcommented, Apr 1, 2016

I’m attaching this sample application that illustrates the problem. TestWebApp.zip

0reactions
MikhailTymchukDXcommented, Apr 12, 2016

Based on the previous experience in CodePlex, it’s about several months per release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValidatorCalloutExtender + CustomValidator - It´s possible?
I can try to call ValidatorCalloutExtender from a CustomValidator, but it´s not work. It´s possíble? My example doesn´t work.
Read more >
Disable Validator but Validator Callout still shows and causes ...
The problem is that with the ValidatorCalloutExtender, when I disable the validator it still marks it as invalid (the textbox flashes white then ......
Read more >
AjaxControlToolkit Versions - Open Source Agenda
... 16.1 if jQuery is used on a page; Item 45 - ValidatorCalloutExtender with CustomValidator causes an error if the httpRuntime setting is...
Read more >
Windows Identity Foundation(WIF) Request validation in .NET ...
NET 4.5 you no longer need this custom validator. Instead the only thing you need to do is setting the RequestValidation option to...
Read more >
ASP.NET - Validation Controls - YouTube
ASP.NET - Validation Controlshttps://www.tutorialspoint.com/videotutorials/index.htmLecture By: Mr. Anadi Sharma, Tutorials Point India ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found