How to maintain page scroll position after page post back in asp.net

In this blog I will write about How to maintain page scroll position after page post back in asp.net.
Suppose there is a page with huge number of inputs and in one case there is some which occurs at bottom of the page. But in post back page scroll position moved to top.

In this case it is very difficult for a user to identify the error and error location on page.
If you have used ajax update panel then you don't have to worry about this. But in case you have have not use ajax update panel, then scroll position of page will not be maintain.

So how we can achieve this?
I know some people will implement this by applying few lines of script.

ASP.Net has already provided the solution for this.

You just add MaintainScrollPositionOnPostback to true in Page directive and you are done with the solutions.

See below line:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" MaintainScrollPositionOnPostback="true" %> 

Comments

Popular

C# 6.0 New Features

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX

What is Cloud Computing - A guide for beginners