Maintain Scroll Position after Postback

When Web pages are posted back to the server, the user is returned to the top of the page. On long Web pages, this means that the user has to scroll the page back to the last position on the page.

In, you can maintain the scroll position after postback. If you set Page.MaintainScrollPositionOnPostBack  to true, your last scroll position will not be lost . Try the following code,

<html xmlns=”“>
<head runat=”server”>
    <title>Untitled Page</title>
    <form id=”form1″ runat=”server”>
    <div style=”height:300px;border:1px solid green;”>
    <div style=”height:300px;border:1px solid red;”>
    <div style=”height:300px;border:1px solid blue;”>
    <div style=”height:300px;border:1px solid yellow;”>
    <asp:Button ID=”btnSubmit” runat=”server” OnClick=”btn_Clcik” Text=”Submit” />


public partial class tv_MaintainScrollPos : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Page.MaintainScrollPositionOnPostBack = true;

protected void btn_Clcik(object sender, EventArgs e)



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s