.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to keep whole page scroll position after asynchronous postback

Posted By:      Posted Date: October 16, 2010    Points: 0   Category :ASP.Net

Hello everybody. i 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();
            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;


but i could not find browser scroll bar id to get its values to get with document.getElementById

thanks for answers

View Complete Post

More Related Resource Links

How to prevent master page postback when update panel asynchronous postback happened


Hello everybody.

When an asynchronous postback happened inside update panel, another postback happens also for MasterPage not only update panel embedded page .

I want to prevent this MasterPage postback .

is this possible ?

think like i have a MasterPage

and another page which is test.aspx which is content page of MasterPage

i have update panel at test.aspx

when asynchronous postback happens at this test.aspx update panel it also loads MasterPage Page_Load

i want to prevent this (it should not also load MasterPage Page_Load)

Thank you

Maintain Scroll position on postback in a asp:panel?


Hi, I'm having a lot of trouble figuring this out. I'm unable to hold the scroll position in the postback in a panel that I set up with a gridview. I tried some of the links offered in the previous threads and it still doesn't seem to be working. Here's the code I have so far, maybe I am missing something small.

<asp:Panel runat="server" ScrollBars="Vertical" 
                 scrollPOS="<%=saveScrollPos.value %>"
                 style="BEHAVIOR: url(<%=ResolveURL('../Includes/ScrollPos.htc')%>); WIDTH: 4000px; HEIGHT: 1000px" >
                 <input id="saveScrollPos" type="hidden" runat="server" name="saveScrollPos"/>
                   <asp:MultiView ID="MultiView1" runat="server">
                    <asp:View ID="View1" runat="server">


Here is the behavior file It points to:

<PUBLIC:ATTACH EVENT=ondocumentready ONEVENT="elementLoad()" />

// DHTML behavior for scrollable

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

jQuery live() and ASP.NET Ajax asynchronous postback

The issue is that normally $(document).ready() is called when the DOM is ready to be manipulated. But this doens't happen after an ASP.NET Ajax asynch postback occurs.

This means that the initial jQuery bindings won't be automatically available after the asynchronous postback is over. I underline "automatically" here because my last post describes more possibilities, how this issue can be worked around.

page postback problem with crystal report


Hi , i am creating crystal report with asp.net it is working showing data but  data is of two page its is take round trip action but report is not show 
until again i click on show button in this it is not propersly showing that data is how.

<br />
    <asp:Button ID="btnShow" runat="server" OnClick="btnShow_Click" Text="Show Report" />
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False" /> CrystalReportViewer1.ReportSource = null; SqlCommand cmd = new SqlCommand(strcmd, c.con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); ReportDocument doc = new ReportDocument(); doc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\rptQuotation.rpt"); doc.SetDataSource(ds.Tables[0]); // login info SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new Tabl

Remeber page postion on postback



I dont know if this is possible or not...

I want the page when refreshed to remember the position that the user was at on the page, for instance if they are scrolled half way down the page when the page posts back can it return to that position on the page?



setting scroll position for a ListBox


I have a ListBox control showing 10 rows.  I have 30 rows total in the listbox.  How do I programmatically adjust the scroll to show the last ten rows?

Some sources have suggested that I set the SelectedItem.  But I am already making selections (myListBox.Items[28].Selected = true, myListBox.Items[29].Selected = true, etc); the listbox scroll is positioned on Item[0] not the first selected item.  I have also tried setting myListBox.SelectedItem in addition to the multiple selection just mentioned but that does not have any affect either.


Change part of a page without full postback


I have a page with two columns. Initially, the left column will contain a list of links that are article titles. Clicking on one of the links will display the text of the article in the right column, keeping the list of titles in the left column. Clicking on another title will clear the text of the first article and display the second. Is there a way to accomplish this without having to repaint the whole page? I would rather not have the whole page resent each time a title is clicked, but rather have the page stay as is and only the contents of the right column get cleared and redisplayed. I assume there's a way to do this with JavaScript, but I don't know how and would appreciate some help. Thanks!

How to make browser scroll to the bottom of page


Hi All,

  How to use asp.net C# to scroll to the bottom on page on post back or programmatically decision? 

Is there a function in Jquery which run only one time no matter load page or PostBack

In asp.net, I can use Method A to run somethings A one time, and somethings A will nor run when page is postback but In JQuery, I hope to run something B one time when the page is loaded, but if I use Method B, the "Somethings B" always run even the page is pastBack, how can I do? Thanks! ------------------Method A------------protected void Page_Load(object sender, EventArgs e){    if (!IsPostBack)    {       //Do Somethings A    } }   ------------------Method B------------$(document).ready(function () {   //Do Somethings B})

"The file is not checked out" on page Postback

Hi there, I have a Publishing site with the Pages library set to "Require documents to be checked out".  As an administrator or member of the site, when i minimise/restore webparts on my page, then perform a postback operation (via some webpart on my page) i get an error saying:  The file is not checked out.  You must first check out this document before making changes. Its as if during the postback after minimising/restoring a webpart SharePoint wants to save that state! How do I stop this from happening?  Is there a personalization setting i am missing?   P.S. Here is a dummy postback operation if you'd like to test it, just paste it into a CEWP: <a id="Test" href="javascript:__doPostBack('Test','')">Test Postback</a>  

Refresh Label on web page without postback

Hi , In my web page i got a button and when this button is clicked it will display message on the label. Example : label text changed from "Start" to "Processing to "Completed". Therefore I want to refresh the label text on my web page so from user site they are able to see the text on Label is changing.. Thanks Linoo  

C# ASP.NET Problem keeping scroll position SelectionMode="Multiple"

Have tried numerous solutions and nothing has worked.  I'm pretty sure that Javascript is required to get this functional. Thanks for your help!    Here is the code for file Search.aspx ===BEGIN<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="search.aspx.cs" Inherits="SearchApp.search" MasterPageFile="~/Site1.Master" EnableViewState="true"%> <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <fieldset> <legend style="text-align:center;"><b>Make Atleast one or multiple selections from one of the following categories</b></legend> <div class="wrapperserach"> <div> <div class="side-a"> County<asp:ListBox ID="Lcounty" runat="server" AutoPostBack="true" SelectionMode="Multiple" OnSelectedIndexChanged="Lcounty_SelectedIndexChanged" Width="140px"> <asp:ListItem value="1">Imperial</asp:ListItem>

Refresh Label on web page without postback

Hi , In my web page i got a button and when this button is clicked it will display message on the label. Example : label text changed from "Start" to "Processing to "Completed". Therefore I want to refresh the label text on my web page so from user site they are able to see the text on Label is changing.. Thanks LeNoo

How to manage postback on crystal Report viewer next page click button clickj

 Hi,       I am using Crystal Report on my ASP.NET Fw. 3.5 project. My report contains 100+ pages. When I click on next page button on crystal report viewer control my whole page gets postback to server and then second page appears. This take same time when first time report gets loaded.     Any suggestion how to imporve user experience in thiss case?   Nilkanth Desai   

Client Javascript runs, but then page errors out when clicking on a control that uses postback

Using this script on a button click <script language="javascript"> function printdiv(printpage) { var headstr = "<html><head><title></title></head><body>"; var footstr = "</body>"; var newstr = document.all.item(printpage).innerHTML; var oldstr = document.body.innerHTML; document.body.innerHTML = headstr + newstr + footstr; window.print(); document.body.innerHTML = oldstr; return false; } </script> After it is done, I can't click on my calendar control.  I was hoping to add somethign that would force a refresh in the script, but nothing I do works. Any thoughts?  Thanks! 

Making asynchronous calls to web services during ASP.NET page processing

Some ASP.NET web applications use web services to get some data that they display to users. Some pages may lay hardly on web services and these pages need some optimization to work better. In this posting I will show you how to use web services behind your ASP.NET page asynchronously and perform a lot of queries to web services. Sample code included! Eneta.Examples.WebAppThreading.zip VS2008 solution | 60KB Asynchronous page processing As an introduction let's see how ASP.NET supports asynchronous calls behind pages. Although we can use our own threading mechanism and avoid what is offered by ASP.NET it is more safe and time saving to use ASP.NET own infrastructure. The image on right that I stole from MSDN article Asynchronous Pages in ASP.NET 2.0 shows you how synchronous and asynchronous pages are processed by ASP.NET. I recommend to read this MSDN article because you can find also other methods for asynchronous calls. I will introduce you how to use PageAsyncTask based calls. If you look at diagram on right you can see that asynchronous processing of registered tasks happens between PreRender and PreRenderComplete events in separate threads. If we have data bound controls on our page we have to move data binding to PreRenderComplete event because this is the closest phase of page processing where asynchronous calls are finished.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend