Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 130723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:59:35+00:00 2026-05-11T05:59:35+00:00

Im working on a project in MVC and have enjoyed learning about it. There

  • 0

Im working on a project in MVC and have enjoyed learning about it. There are a few growing pains but once you figure them out it’s not bad. One thing that is really simple in the WebForms world is maintaining the scroll position on a page. All you do is set the MaintainScrollPositionOnPostback property to true. However, in MVC, Im not using postbacks so this will not work for me. What is the standard way of handling this?

Edit: Ajax is acceptable, but I was also wondering how you would do it without AJAX.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:59:35+00:00Added an answer on May 11, 2026 at 5:59 am

    The way MaintainScrollPositionOnPostback works is that it has a pair of hidden fields: __SCROLLPOSITIONX and __SCROLLPOSITIONY

    On a postback, it sets these,

    function WebForm_GetScrollY() {     if (__nonMSDOMBrowser) {         return window.pageYOffset;     }     else {         if (document.documentElement && document.documentElement.scrollTop) {             return document.documentElement.scrollTop;         }         else if (document.body) {             return document.body.scrollTop;         }     }     return 0; }  function WebForm_SaveScrollPositionSubmit() {     if (__nonMSDOMBrowser) {         theForm.elements['__SCROLLPOSITIONY'].value = window.pageYOffset;         theForm.elements['__SCROLLPOSITIONX'].value = window.pageXOffset;     }     else {         theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX();         theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY();     }     if ((typeof(this.oldSubmit) != "undefined") && (this.oldSubmit != null)) {         return this.oldSubmit();     }     return true; } 

    and then it calls RestoreScrollPosition:

    function WebForm_RestoreScrollPosition() {     if (__nonMSDOMBrowser) {         window.scrollTo(theForm.elements['__SCROLLPOSITIONX'].value, theForm.elements['__SCROLLPOSITIONY'].value);     }     else {         window.scrollTo(theForm.__SCROLLPOSITIONX.value, theForm.__SCROLLPOSITIONY.value);     }     if ((typeof(theForm.oldOnLoad) != "undefined") && (theForm.oldOnLoad != null)) {         return theForm.oldOnLoad();     }     return true; } 

    But as most people said, MVC should be avoiding postbacks anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an ASP.Net MVC project and have been learning a few little
I have been working on a little MVC project to assist in my self-learning
I have set up an ASP.NET MVC project, and everything is working great, but
I'm working on a Spring MVC project, and I have unit tests for all
background:Me and my coworkers are working on asp.net mvc project ... we have a
I'm working in an ASP.NET MVC project where I have created a two LinqToSQL
I'm working on an asp.net-mvc project. I have an Items table and a Tags
I have this sample MVC project using jQuery grid. There is only one problem
I am working on a MVC project where I have copied a lot of
I am working on a project using .Net mvc. I have a csharp class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.