Retain scroll position after postback

Posted by Sharadgupta2110 under ASP.NET on 11/16/2010 | Points: 10 | Views : 2061 | Status : [Member] | Replies : 4
Hello All,

I am working on ecommerce site in asp.net, my problem is that if i select any product from product page from any block and go to the another page like checkout page etc,
after that if i returned to that page which i have visited recently to select products, so i want to retain scroll position after postback and want to show only that block of products.

Thanks in advance..

With Regards
Sharad Gupta

Sharad Gupta


Responses

Posted by: Madhuk on: 11/16/2010 [Member] Starter | Points: 25

Up
0
Down
You can set it programmatically
Page.MaintainScrollPositionOnPostBack = true;
or
In the page declaration
<%@ Page MaintainScrollPositionOnPostback="true" %>


Sharadgupta2110, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sharadgupta2110 on: 11/16/2010 [Member] Starter | Points: 25

Up
0
Down
Thanks for quick reply, i have tried this but it is not working.
please give me another code..

Sharad Gupta

Sharadgupta2110, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 11/16/2010 [Member] Starter | Points: 25

Up
0
Down
It should work, look at the demo http://www.dotnetfunda.com/tutorials/controls/gridview.aspx, try clicking edit in the gridview and it will postback and maintain its position.

You might have some other javascript error that is stopping it to happen.


Regards,
Raja, USA

Sharadgupta2110, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/31/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi Sharadgupta2110

you use only page this directive

MaintainScrollPositionOnPostback="true"

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

Best Regard's
Prabhakar

Sharadgupta2110, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response