ASP.Net validation summary causes page to jump to top

前端 未结 9 1067
时光说笑
时光说笑 2020-12-08 06:09

I have a simple form with a few required field validators and a validation summary control. When I submit the form, the client validation will cause the form to ju

9条回答
  •  旧时难觅i
    2020-12-08 07:01

    This is a known bug, as documented on Microsoft Connect. The relevant issue has the basis for the best work around:

    var ValidationSummaryOnSubmitOrig = ValidationSummaryOnSubmit;
    var ValidationSummaryOnSubmit = function() {
        var scrollToOrig = window.scrollTo;
        window.scrollTo = function() { };
        var retVal = ValidationSummaryOnSubmitOrig();
        window.scrollTo = scrollToOrig;
        return retVal;
    }
    

提交回复
热议问题