Click here to Skip to main content
13,045,564 members (72,612 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm new to; I'm having a problem with autopostback on a dropdown list.
Each time a selection is made, the autopostback fires as it should BUT the page always scrolls to the top.

I'm using Firefox 17.0.1 and have also tested on Chrome 23.0.1271.97 m; javascript is enabled.

I have tried:

Page.MaintainScrollPositionOnPostBack = true;
in the code behind (Load event), also in MasterPage code behind

in the page declaration

<pages maintainScrollPositionOnPostBack="true" />
in the web.config

on various controls on the page

all to no effect. The problem persits. I can see nothing in the MasterPages or the current page to cause this.

Please help..
Posted 4-Jan-13 16:41pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I guess you are missing use of SetFocus along with MaintainScrollPosition.

2 options:
1. try MaintainScrollPosition page attribute with SetFocus method. Refer: MSDN: Page.MaintainScrollPositionOnPostBack Property [^] OR

2. you can keep track of the scroll position on client side before the onchange event fires. Restore the scroll position back to what you stored last time after the page refresh. Refer: Part of the article provides way to do it[^]

Earlier, Smartnavigation = true property was used. But now, option 1 is the new one.
[ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack.")]
public bool SmartNavigation { get; set; }

Refer: MSDN: SmartNavigation[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100