.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Maintain Scroll Position on Postback within UpdatePanel

Posted By:Sanjeeb Lenka       Posted Date: September 13, 2013    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

ecently I faced problem to maintain scroll position in my page which having A grid with some radio button and check box with autopostback
 

Recently I faced problem to maintain scroll position in my page which having A grid with some radio button and check box with autopostback within a Updatepanel.
 
The main problem is when a postback occur the page is moving to top. i tried a lot and finally got the solution.

if you are using IE then its very simple just put the code in your page directive.

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default"

MaintainScrollPositionOnPostback="true" %>

 

but it will not work in Firefox for that you have to add one browser file into your website

Right click on solution explorer > Add New Item

Select Browser File and add it to App_Browsers folder.

Add MaintainScrollPositionOnPostback capability to this browser file as written below.
 

<browsers>

  <browser refID="Mozilla">

      <capabilities>

        <capability name="supportsMaintainScrollPositionOnPostback" value="true" />       

    </capabilities>   

  </browser>

</browsers>


Some times this also not work,

Then a simple solution just add a blank Update panel after the grid and onpostback just put the focus to that update panel
it will work in any browser.
 

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

        </asp:UpdatePanel>  
 

 in cs postbackevent

updatepanel1.Focus();

If any problem just feel free to ask or any modification reply.

If anybody want source just give a comment.

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend