Web Forms :: How To Retain Scroll Position On Postback
Jul 23, 2010How can we retain Panel scroll position on postback without using any cookies.
View 6 RepliesHow can we retain Panel scroll position on postback without using any cookies.
View 6 RepliesI have a gridview with scroll enabled. Means i have a gridview like this-
[Code]....
I want during postbacks scroll position of my gridview will not change. I have tried many articles on the web, but in some scrolling is retained only in IE, in some others scrolling position changes on clicking edit link of gridview. I want a good solution for IE, FF, Chrome
I have a page that uses AJAX updatepanels. On this page, we have some radio buttons with Autopostback set to true. The problem is that after the postback, the control was losing focus so that when the user would hit tab, control would be restored to the first control on the page and not the drop-down which fired the event. As a fix, I wrote some set focus code in the radio button's oncheckchanged event. This seems to have fixed the problem with the focus. The problem I have is that the browser loses its scroll position every time I click on one of these radiobuttons. Is there a way to maintain scroll position? Maybe there is another way to resolve my original problem of setting focus that will prevent this from happening.
View 6 Replies[URL]
I have got the gridview to populate from my own datatable and there are quite a few results in the table. As a result I have a scroll bar on my gridview.
If there is only a few results the gridview works perfectly, however; When I select a row further down in the scroll it selects and highlights but refreshes the view to the top of the gridview.
I have implemented the "slimScroll" in a div. Prior to this implementation, I was using the asp.net inherent scrolling and was able to use the Maintain Scroll PositionOnPostback="true" at the Page level and that worked well; but now, this no longer works.Â
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SBN_Messages.aspx.vb"
Inherits="ShopBuyName_Test_Site.SBN_Messages" MaintainScrollPositionOnPostback="true" %>
<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[code]....
I have some collapse able anhcor link tags on a page that reveal some text when clicked on i.e.: [+] Topic This is all done in javascript client side. I would like to maintain the users scroll position on the page when these links are clicked on. They dont cause a postback as iv mentioned above its client side javascript.
View 6 RepliesI have an asp.net listbox with 15 rows and auto postback when the selected item is changed. This works as expected but, when the form is re-loaded, IE scrolls the list so that the last selected item is now the top visible item in the list. This produces a confusing/jumpy effect for the users and makes the listbox more difficult to use than it needs to be.
Is there any way to get the list scroll position to stay as it was before the postback? i.e, if I select an item from the middle of the listbox, the listbox is scrolled to the same point after postback.
I am using .Net 3.5 but no AJAX.
I tried some methods to maintain scroll position on postback but none worked they are
1) In page declaration MaintainScrollPositionOnPostback="true"
2) In Code behind Page.MaintainScrollPositionOnPostBack = true
3)In web.config file in <system.web>Â section <pages maintainScrollPositionOnPostBack="true" />
I am not using any updatepanel.
I have some problems with maintaining scroll position after postback. First time I experienced the problem was when I (believe) added Combobox control from AJAX control Toolkit and/or UpdatePanel from AJAX Extensions. The problem is when I do the postback on the page the page is loaded at the top and not where I did the postback. Actually, this wouldn't be a problem if it isn't happening on a very large form. I have already tried using MaintainScrollPositionOnPostback="true", but it wasn't helpful at all. I can provide the code if needed, but I don't think it would be of any use because I have comboboxes inside update panels which are rebinded on a button click.
View 1 Repliesi am using asp.net 4.0 iis 7.5 microsoft visual studio 2010
what i want is keep whole page (browser) scroll position (not a div or panel) when asynchronous postback happened (update panel) how can i do this actually i had a function which can keep div scroll bar position after postback like this
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = document.getElementById('Main').scrollLeft;
yPos = document.getElementById('Main').scrollTop;
}
function EndRequestHandler(sender, args) {
document.getElementById('Main').scrollLeft = xPos;
document.getElementById('Main').scrollTop = yPos;
}
</script>
bu i could not find browser scroll bar id to get its values to get with document.getElementById
I have a gridview that putted in ASP.NET Panel. both of panel and Gridview are in an UpdatePanel. there is a column in gridview that Causes Partial PostBacks. i want to Maintain Panel Scroll position on those postbacks.
View 1 Repliesi used the dropdown list in user control.when i select the dropdownlist that scroll bar went to top.how can i maintain the scroll bar position in that situation?
View 3 RepliesI have found many articles claiming to show you how to set the scroll position of a ListBox, but what they really end up showing you is how to set the SelectedIndex of a ListBox.
Here is what I need: a databound ListBox that's usually going to have around 25 items in it. When the page loads, ALL of the items in the ListBox are selected, and the ListBox is scrolled all the way to the bottom.
I've got the "All items Selected" requirement already, but I can't figure out how to get the "Scroll to the bottom" done.
I have taken a div inside the UserContol.
this usercontrol is placed in a page having master page.
In div i have checkboxlist control .
I want to preserver scroll position of while postback.
I have also used UpdatePanel in which i have placed this user control.
I have also triedMaintainScrollPositionOnPostback="true"
but does not work.
My page structure is this:
Masterpage > contentplacehoder (child Page) > UpdatePanel > User control > div > asp:CheckboxList
I want to maintain the scroll position of a page. So I try to get the page cordinates and set the position on the page load (actually I've a postback in my page) using JS as follows. What I've done is on a client click on an image get the page cordinates and keep in a hidden field.
[Code]....
GetScollerPosition function invoke in an image click event. But it's not work as I expected, the SetScrollPostion always find the value of hidden fields as zero.
I have this working in several pages in my site but in one page it wont work!
this is the hierarchyof the page.
I have a treeview in a div,in an asp:panel, in an updatepanel in a user control. the panel is shown/hidden using the ajax modalpopupextender.
this user control is placed in a content page (using a master page).
Now that you got the above, I'll let you know what ive tried already.
I tried doing this:(which works perfectly when the treeview is placed simply in an aspx page)
[Code]....
tried using also :
[Code]....
Basically i kept playing around with it trying different ways but seems like the selected node is just not visible even though i call this JS function after i have selected the Node in code behind.
[Code]....
I am trying to use an anchor tag to automatically scroll down to "position1" when the page loads.
I have created this name tag in the .aspx page and then trying to redirect to that tag in the page_load event but this results in that the page doesn´t load at all and cant be seen in the browser:
I have a multiview control on a page with multiple child view controls. As the ActiveViewIndex is changed when I nagivate between views, I'd like to reposition the scroll position of the browser. For instance, when toggling between a very long page with a huge gridview (page 1) and a smaller page that follows (page 2), I'd like my scroll position to start back at the top of the page when I navigate to the smaller page. Currently, if I scroll down on Page 1 and select an item that navigates me forward to page 2, the scroll position is maintained and I start too far down the page when Page 2 displays. I have programatically set MaintainScrollPosition to false on Page_Load so this should not be a factor.
View 3 RepliesI am building an application using masterpages, one of the pages contains dynamic gridviews with textboxes using templates. The textboxes have the autopostback enables to allow the calculation of the numeric values entered in each row.
The grid has 3 cols (3rd col has the total of the first and sec cols) the problem is that when i change the textbox (therefore a postback is created) the page scrolls up.
I tried the Page.MaintainScrollPositionOnPostBack = True but it does not work. Can i use any other method to solve this poblem.?
I tried out the solution posted for [URL]
Is there any way to maintain scroll position if I need to re-direct to same page?
I have an asp.net c# web forms application with a formview. Â When I click "Edit" on the formview, I have set the focus to a textbox. Â This works just fine. Â
protected void fv_comp_status_list_DataBound(object sender, EventArgs e) {
if (fv_comp_status_list.CurrentMode == FormViewMode.Edit) {
TextBox tb = (TextBox)fv_comp_status_list.Row.Cells[0].FindControl("pol_numTextBox");
tb.Focus();
} }
The problem is that the textbox is at the bottom of the screen. Â I want to set focus on the textbox and also have it move (scroll) to the top of the screen. Â This will allow the user to see the entire form, withhout having to scroll initially. Â
How can I modify the code to set the textbox (pol_numTextBox) at the top of the page on DataBound once the focus is set?
How can i place and use an anchor in MVC to retain my position. I have a drop down in a form tag buried in my very long page and i need to to retain the position where my dropdown is located on any selection made by my dropdown(only on selection not on intial or very first pageload).
View :
<form id="frmSelectMe" method="post" action="GetAllInfo" >
<dt><label for="SelectMe">State Name:</label></dt>
<dd>
<select id="SelectMe" >
<option value="<%= String.Format("{0:d}", Something.DateValue) %>" >......
I have a gridview inside a div and everytime i scroll to the bottom rows of gridview, it throws back to the top of the grid.
<div id="divGvIncidentDetail" runat="server" style="overflow:scroll; min-height: 10px; max-height: 250px;" onscroll="SetDivPosition()">
<asp:GridView ID="gvIncidentDetail" runat="server" ...>
</asp:GridView>
</div>
To prevent it, i tried implementing following javascript code by user Sun Rays:
<script type="text/javascript">
window.onload = function () {
var strCook = document.cookie;
if (strCook.indexOf("!~") != 0) {
var intS = strCook.indexOf("!~");
var intE = strCook.indexOf("~!");
var strPos = strCook.substring(intS + 2, intE);
document.getElementById("divGvIncidentDetail").scrollTop = strPos;
}
}
function SetDivPosition() {
var intY = document.getElementById("divGvIncidentDetail").scrollTop;
document.title = intY;
document.cookie = "yPos=!~" + intY + "~!";
}
</script>
I get the following error when i run the code: Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object Am i missing something? or is there any other better solution to maintain the scroll position
I have a datalist within a table and it scrolls horizontally. The data is set up to progress from past to future. By default the page loads with the table scrolled all the way to the left, and therefore displaying data which is furthest in the past. I would prefer for the table to load with the scroll bar in the middle, so that data at the split between past and future is displayed and the user can go further each way as he desires. how to set the focus within the table to let my datalist load exactly where I want it?
View 14 Replies I have a scroll bar in GridView. I m maintaining scroll bar position with javascript. It is working fine.
I have one more datagrid in the same page. I want to apply same Javascript to that datagrid also. Here is the javascript I used.
<script language="javascript" type="text/javascript">
var scrollTop;
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args)
{
var m = document.getElementById('divexample2');
scrollTop=m.scrollTop;
}
function EndRequestHandler(sender, args)
{
var m = document.getElementById('divexample2');
m.scrollTop = scrollTop;
}
</script>
and here is the reference [URL]