My web page utilizes an UpdatePanel and validation. Due to specific requirements, I need to show a custom model when validation fails. So far, the only way I've achieved this is by overriding the Page_ClientValidate client-side function:
function Page_ClientValidate(validationGroup) {
Page_InvalidControlToBeFocused = null;
if (typeof(Page_Validators) == "undefined") {
return true;
}
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i], validationGroup, null);
}
ValidatorUpdateIsValid();
ValidationSummaryOnSubmit(validationGroup);
Page_BlockSubmit = !Page_IsValid;
if(!Page_IsValid)
{
displayError();
}
return Page_IsValid;
}
While this method works well, I've observed that in an UpdatePanel, when new content is generated, the ScriptResource.axd files containing the original Page_ClientValidate are re-downloaded, overwriting my override.
As a result, errors are displayed next to the fields but my displayError function is not called.
Do you have any suggestions on how to address this issue?
I am considering monitoring the error spans to check if they become visible, although I'm unsure if this approach is excessive at the moment.
Thank you,
Gavin