retain scrollbar position
-
In a C# 2010 web form application that uses web form controls, I have a scrollbar used on a panel control. The user would like to be able to retain the scrollbar position while they are on the current web form page. They would like the scrollbar to retain its position until they have pointed to the next web form page. Since I do not know how to accomplish this goal, I am wondering how to accomplish this task. The asp.net markup looks like the following:
-
In a C# 2010 web form application that uses web form controls, I have a scrollbar used on a panel control. The user would like to be able to retain the scrollbar position while they are on the current web form page. They would like the scrollbar to retain its position until they have pointed to the next web form page. Since I do not know how to accomplish this goal, I am wondering how to accomplish this task. The asp.net markup looks like the following:
I believe you are asking on how to persist with scroll position on page postbacks. If so, 2 options: 1. try
MaintainScrollPosition
page attribute. Refer: MSDN: Page.MaintainScrollPositionOnPostBack Property [^] OR 2. you can keep track of the scroll position on client side before the onchange event fires. Restore the scroll position back to what you stored last time after the page refresh. Refer: Part of the article provides way to do it[^]Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
-
I believe you are asking on how to persist with scroll position on page postbacks. If so, 2 options: 1. try
MaintainScrollPosition
page attribute. Refer: MSDN: Page.MaintainScrollPositionOnPostBack Property [^] OR 2. you can keep track of the scroll position on client side before the onchange event fires. Restore the scroll position back to what you stored last time after the page refresh. Refer: Part of the article provides way to do it[^]Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
Thanks for your answer. However that did not work. There is no postback involved most of the time. Basically I placed a checkbox list control within a panel that has a scrollbar. When the user has finished selecting all the items in the checkbox list control, they move on to other items on the web form page to enter. They have not clicked the 'next' button yet. There is no postback. The user does not want the scrollbar to go to the top area of the scroll. They want to stay where they left off entering selections. Thus do you know of other ways I can maintain the scrollbar position? I am currently not using ajax controls on this webpage.
-
Thanks for your answer. However that did not work. There is no postback involved most of the time. Basically I placed a checkbox list control within a panel that has a scrollbar. When the user has finished selecting all the items in the checkbox list control, they move on to other items on the web form page to enter. They have not clicked the 'next' button yet. There is no postback. The user does not want the scrollbar to go to the top area of the scroll. They want to stay where they left off entering selections. Thus do you know of other ways I can maintain the scrollbar position? I am currently not using ajax controls on this webpage.
From your code post it looks like there should be a postback when the user checks a checkbox. The checkbox has the AutoPostBack property set to true, correct? Many links on this if you google here is one example http://stackoverflow.com/questions/8797798/asp-net-maintain-scroll-position-o-post-back-in-ever-updating-firefox-chrome[^]
-
From your code post it looks like there should be a postback when the user checks a checkbox. The checkbox has the AutoPostBack property set to true, correct? Many links on this if you google here is one example http://stackoverflow.com/questions/8797798/asp-net-maintain-scroll-position-o-post-back-in-ever-updating-firefox-chrome[^]
I think what the OP is trying to say, Is that he has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.
-
I think what the OP is trying to say, Is that he has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.
-
I guess I misunderstood this statement...
Quote:
They have not clicked the 'next' button yet. There is no postback.
-
I think what the OP is trying to say, Is that he has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.
You are correct. This is what I am trying to say: There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.
-
You are correct. This is what I am trying to say: There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.
I would imagine adapting something like the accepted answer in the stackoverflow link below would work. Since this is a server control you would need to assign the attribute for the onscroll client side event. Here are a couple links you might want to check out http://forums.asp.net/t/1045266.aspx/1[^] http://stackoverflow.com/questions/1094589/maintain-scroll-position-of-a-div-within-a-page-on-postback[^]
-
You are correct. This is what I am trying to say: There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.
Aw, The page lifecycle OnInit, Intialize the html elements on the page onLoad, load values for the html elements once the page does onInit, the html elements are cast in stone, and will not change Once the page does onLoad, you can populate values in the html elements During a postback to the server, the html elements are rock solid, and the values will remain, but things like scroll position reset back to default. The page does not have the ability to remember little details like scroll position MaintainScrollPosition is for the scroll of the whole page, and not a panel. But, maybe, instead of page.MaintainScrollPosiiton, you could do panelName.MaintainScrollPosition Other that that, you would have to take a measurement of the position, record it, and restore it back to the value, in theory I don't have an answer, I would have to think about it and experiment. A quick search gets this document.getElementById('box').scrollTop Persisting the scroll position of a DIV on AJAX postbacks [^] Maintain Scroll Position in Panel, Div[^] http://michaelsync.net/2006/06/30/maintain-scroll-position-of-div-using-javascript-aspnet-20[^] http://forums.asp.net/t/1359867.aspx[^]
-
I would imagine adapting something like the accepted answer in the stackoverflow link below would work. Since this is a server control you would need to assign the attribute for the onscroll client side event. Here are a couple links you might want to check out http://forums.asp.net/t/1045266.aspx/1[^] http://stackoverflow.com/questions/1094589/maintain-scroll-position-of-a-div-within-a-page-on-postback[^]
-
Thanks for your answer. However that did not work. There is no postback involved most of the time. Basically I placed a checkbox list control within a panel that has a scrollbar. When the user has finished selecting all the items in the checkbox list control, they move on to other items on the web form page to enter. They have not clicked the 'next' button yet. There is no postback. The user does not want the scrollbar to go to the top area of the scroll. They want to stay where they left off entering selections. Thus do you know of other ways I can maintain the scrollbar position? I am currently not using ajax controls on this webpage.
dcof wrote:
There is no postback involved most of the time.
dcof wrote:
There is no postback.The user does not want the scrollbar to go to the top area of the scroll. T
Well, not possible! Without a postback, page would not return scroll to top by itself! My answer still holds. Try out. Both the options. For second one, use form onsubmit() event to store the scroll position and then restore it on form load.
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
-
Thats too funny. Looks like you covered it a little better than I did though so good job to you!
Thanks, I figured the question was wrong, and the OP had no clue what was happening there. Well, hopefully, he learned something there today. These asp.net questions are getting harder to answer because the way the questions are phrased make no sense to me. One day, someone will ask a really good question Over and out, time to sleep
-
In a C# 2010 web form application that uses web form controls, I have a scrollbar used on a panel control. The user would like to be able to retain the scrollbar position while they are on the current web form page. They would like the scrollbar to retain its position until they have pointed to the next web form page. Since I do not know how to accomplish this goal, I am wondering how to accomplish this task. The asp.net markup looks like the following:
Use Smartnavigation = true property hope it will suits your requirement.
-
Use Smartnavigation = true property hope it will suits your requirement.
Oh yes, I totally forgot about it! :doh:
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
-
Oh yes, I totally forgot about it! :doh:
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]
You probably forgot because your first suggestion is the replacement for the deprecated property.
[BrowsableAttribute(false)]
[ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
public bool SmartNavigation { get; set; }http://msdn.microsoft.com/en-us/library/system.web.ui.page.smartnavigation.aspx[^]
-
You probably forgot because your first suggestion is the replacement for the deprecated property.
[BrowsableAttribute(false)]
[ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
public bool SmartNavigation { get; set; }http://msdn.microsoft.com/en-us/library/system.web.ui.page.smartnavigation.aspx[^]
5! Thanks for bringing back some part of memory. :)
Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]