ASP.Net validation summary causes page to jump to top

前端 未结 9 1042
时光说笑
时光说笑 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条回答
  • 2020-12-08 07:02

    Look at setting the target schema for your html.

    Try http://msdn.microsoft.com/en-us/library/6379d90d(VS.71).aspx

    Prior to VS 2005 you could set the schema on a page by page level.

    Just a thought.

    0 讨论(0)
  • 2020-12-08 07:08

    The page is going to jump to wherever your validation summary is. If you'd like it to stay near the bottom, move the validation summary down near the submit button.

    EDIT, you can also try turning the validation summary off.

    0 讨论(0)
  • 2020-12-08 07:09

    As stated by cleek's answer, this is a known bug having workarounds.

    Here is bdukes one, which looks to me as the best currently available.

    (function () {
      var originalValidationSummaryOnSubmit = window.ValidationSummaryOnSubmit;
      window.ValidationSummaryOnSubmit = function (validationGroup) {
        var originalScrollTo = window.scrollTo;
        window.scrollTo = function() { };
        originalValidationSummaryOnSubmit(validationGroup);
        window.scrollTo = originalScrollTo;
      }
    }());
    

    (He has not posted it directly here on SO, and now the connect issue seems to require registration for being seen, which renders his workaround harder to access.)

    0 讨论(0)
提交回复
热议问题