Prevent aspx page from scrolling to top on postback

I have a aspx that when the page postback it scrolls all of the way to the top of the from on a postback.  I'm trying to prevent this from happening but i cant find a solution.  I have tried setting MaintainScrollPositionOnPostback="true" and i have found a couple of examples of javascript that should prevent this from happening but i cant seen to find a solution.  

I am using a masterpage and i am guessing that is probably why i cant get this to work.  I looking for a solution to this problem.  Any help would be greatly appreciated.

Im using vb.net, visual studio 2010

Thanks
Mike_StevensAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Have you tried implementing ajax?

If you do a partial postback the page won't scroll.

The simplest way to do this is to add an <asp:updatepanel> around the offending control that causes the control.

Pattern is:
 <!-- top of page . . .  note there could only be one per page so if you have one on the master page you're fine. -->
   <asp:ScriptManager runat="server" id="sm1" />

<!-- in your content page -->
<asp:UpdatePanel runat="server" id="up1">
<ContentTemplate>
     <!--your controls go here -->
</ContentTemplate>
</asp:UpdatePanel>

Open in new window

0
CamilliaCommented:
I have this.MaintainScrollPositionOnPostBack = true;  in the Page_load of the page that uses the Master page.
0
John Gates, CISSPSecurity ProfessionalCommented:
Put this in your page directive:  smartNavigation="True"

example
<%@ Page Language="vb" AutoEventWireup="false" Inherits="yourapp" smartNavigation="True" Codebehind="yourpage.aspx.vb"  meta:resourcekey="PageResource1" %>

-D-
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

John Gates, CISSPSecurity ProfessionalCommented:
smartNavigation is the replacement for MaintainScrollPositionOnPostBack = true

-D-
0
Mike_StevensAuthor Commented:
I should have mentioned in my original post that i am using a update panel.

I tried all of the above suggestions and still the same result.
0
CamilliaCommented:
Have you tried this solution?

Possible Solution
0
John Gates, CISSPSecurity ProfessionalCommented:
I use an update panel on the page where I gave you the sample directive...  Works fine and remains where it is without scrolling back...  Did you actually try the smartNavigation = True or just assume it didn't work?  The page that directive comes from is an online payment page with an ajax enabled blockui for credit card information submission.  It relies on a scriptmanager on the page..  But I have learned how and where you add the update panel etc in the code makes a difference..  Maybe if you post your codebehind page and the aspx page we can help further...

-D-
0
John Gates, CISSPSecurity ProfessionalCommented:
<%@ Page Language="C#" AutoEventWireup="true" MaintainScrollPositionOnPostback="true" CodeBehind="WebForm7.aspx.cs" Inherits="MyProject.WebForm7" %>

Is a way to address this too.  I said it backwards in my first post as smartNavigation=True is the old method...  I use .NET 4.5 on my site and I find the directive still works better then the MaintainScrollPositionOnPostback but I find putting it in the page directive of the aspx seems to yield better results than in the code behind in my experience anyway.

-D-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kyle AbrahamsSenior .Net DeveloperCommented:
what kind of controls are you working with?  And what's within the update panel?

Is it possible to narrow down the size of the update panel or what's overflowing it that's causing it to scroll?

Can you post your front end?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Applications

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.