NayeemKhan
NayeemKhan

Reputation: 1230

How to lock scrollbar of the browser using C#.net code behind(.cs page)?

Can anybody tell me how can i save the location of the browser scrollbar. I have a form kind of page containing some postbacks, after postback i want the page location to be same where the user was. I mean the part of the page (middle or down or up). Currently, after postback the scroll is up, ie its displaying the upper part of the page.

Thanks in advance

Upvotes: 0

Views: 1580

Answers (3)

Ahmed
Ahmed

Reputation: 655

In your asp.net page markup (top line of your aspx page) set MaintainScrollPositionOnPostBack = true; however it sometimes does not work properly with some third party controls, so if you're just using standard asp.net controls you're good.

Upvotes: 0

Jayantha Lal Sirisena
Jayantha Lal Sirisena

Reputation: 21366

you can set in your code behind

 System.Web.UI.Page.MaintainScrollPositionOnPostBack = true; 

this will keep the scroll position in the page only

if you wan to do it for all pages use Web.config page section

<pages maintainScrollPositionOnPostBack="true" />

Upvotes: 1

Sergio
Sergio

Reputation: 8259

You can:

  • At Page level set the page directive like <%Page smartNavigation="True" %>
  • At Application level set smartNavigation="true" in web.config

Upvotes: 0

Related Questions