javascript - How to stop default scrolling after postback? -


i want scroll top after post back. in login page when click on login button , if there validation error message scrolls bottom. not bottom scroll down first text field. want stop default scrolling , want scroll top. using following code:

<script type="text/javascript">      jquery(document).ready(function () {      jquery("#scrolltop").val(0);      var prm = sys.webforms.pagerequestmanager.getinstance();      prm.add_endrequest(function (s, e) {          jquery("#scrolltop").val(0);          window.scrollto(0, 0);          $('html, body').animate({ scrolltop: 0 }, 'fast');         // alert('postback end!');      });      prm.add_beginrequest(function (s, e) {          jquery("#scrolltop").val(0);          window.scrollto(0, 0);          $('html, body').animate({ scrolltop: 0 }, 'fast');      });  }); 

this code working fine after endrequest page scroll bottom. using code page scrolls top , middle of page.

please me resolve this.

if c# , asp.net, might after property called maintainscrollpositiononpostback

https://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback(v=vs.110).aspx


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -