Determine which controls fail on the ASP.NET web page.

Is there an easy way to determine which controls are not validated on an ASP.NET website? I am debugging a page that Page.Validate("group")fails, but I don’t know which controls made the page fail. The page is quite large, and the code is a bit messy, so I hope I can get a list of control IDs that don't check .

I tried adding ValidationSummary to the page, but it just gives me the standard “please fill in the value” message for the three controls that are unsuccessful because this standard text is used on the website.

+3
source share
1 answer

Here , as I did on the client side.

function ValidationCatcher()
{
    //force .net validation
    Page_ClientValidate();

    var count = 0;
    for(i=0; i < Page_Validators.length; i++){
        if(!Page_Validators[i].isvalid)
        {
            //do whatever
            count = count+1;
        }
    }
    //set msg for dialog message
    //do whateveryou want here
    alert(count);

}

function ValidatorFocus()
{
    var i;
    for (i = 0; i < Page_Validators.length; i++) {
        if (!Page_Validators[i].isvalid) {
            document.getElementById(
            Page_Validators[i].controltovalidate).focus();
            break;
        }
    }
}
+1
source

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


All Articles