.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

Maintain Scroll position on postback in a asp:panel?

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

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

View Complete Post

More Related Resource Links

Using jQuery .hide() and .show() on panel sets doesn't maintain status through postback. Viewstate

I'm using jQuery against a set of three asp panels.  I set up an 'onChange' function for a dropdown list that dictates which panels to hide and show based on the UI selection.When the page first loads, one of the panels will be shown, the others will be hidden.  Let's say pnlOne is showing because the dropdown has option 1 selected.  This is done on the server with this:pnlOne.Style.Add("display","block");//and all the other panels are set to ".Style.Add("display","none");" based on logic.Then, the user selects a different value in the dropdown.  Let's say they select option number 2.  With javascript and jQuery I do this:$("#<%=pnlOne.ClientID %>").hide();$("#<%=pnlTwo.ClientID %>").hide();$("#<%=pnlThree.ClientID %>").hide();switch($("#<%= ddlOptionNumber.ClientID %> option:selected").text()){case "1":$("#<%= pnlOne.ClientID %>").show();break;case "2": etc.,}The issue is when the page posts back.  I'm running client side validation only at this point.  (Even if I add client side in the future I will still run client side as well to avoid security issues.)  When the validation functions detect an issue and the page returns to be displayed, the original panel (pnlOne)

How to keep whole page scroll position after asynchronous postback


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

Returning Focus (Position) in Panel After PostBack


VWD 2008 Express.  Visual Basic.

I have a gridview control within a panel control.  The gridview can contain up to 128 rows.  The panel is 300px high and has a vertical scroll bar that allows me to scroll to the row I want to see or edit in my gridview.  When I click the "Edit" button on an item within my gridview, the page posts back and returns to panel scrolled all the way back to the top.  I have to then scroll back down to get to the item I want to edit in my gridview (which has correctly been placed in edit mode).  How can I make the panel return to its postion (or stay in its postion) after a postback without me having to manually scroll back down?  Thanks for the help.

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

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.


Checkbox will show panel based on selection without postback.. how to do



I have Two Checkbox in my asp.net textbox..

First what i want is

based on two checkbox user has to be select any one only..

if checkbox1 is selected then Panel1 visible true without postback

if checkbox2 is selected then Panel2 visible true without postback

Update Panel only doing full postback

I have a page with a TabContainer with 3 tabs.  Within each tab, I have an UpdatePanel.  One of my UpdatePanel's update mode is set to "conditional" and I've added an asyncpostbacktrigger with the controlId="btnClearEmail1" and the eventname="Click".  When I run the page and click the button assigned to the asyncpostback trigger, the page will do a full postback.  Am I forgetting something?  How can I get it to just refresh what is inside the UpdatePanel?  <asp:tabcontainer id="ajaxTabContainer" runat="server"> <asp:tabpanel id="ajaxTabCustomerInfo" runat="server" headertext="Customer Information" visible="true"> <contenttemplate> ... [clipped for brevity] </contenttemplate> </asp:tabpanel> <asp:tabpanel id="ajaxTabSiteBranding" runat="server" headertext="Custom Site Branding"> <contenttemplate> <asp:updatepanel id="UpdatePanel2" runat="server"> <contenttemplate> ... [clipped for brevity] </contenttemplate> </asp:updatepanel> </contenttemplate> </asp:tabpanel> <asp:tabpanel id="ajaxTabEmails" runat="server" headertext="E-mail Notifications"> <contenttemplate> <div> <asp:panel

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>

Making a scrollable panel scroll with mousewheel just by hovering mouse

Hi, I have a particular problem with a possible solution and I am interested in hearing peoples opinions if it is the right way to go about it (or not  ) Some applications I have come across, such as Firefox, will allow the user to scroll the document window just by hovering the mouse over the display area and using the mouse wheel. You don't have to focus / select the display area first. With Firefox, the address bar can have the focus and the keyboard input but you can still scroll the document. Contrasting with IE and Visual Studio, you have to click into the document area before it responds to mouse wheel messages. In my winforms app, I have a tab control with several scrollable tabpages as well as scrollable panels in other places. Some of these just display data and don't have controls that can be focused or tabbed into. I would like to emulate the firefox behaviour described above. What I have done is created a class, ScrollPanelMessageFilter, that implementes System.Windows.Forms.IMessageFilter and that takes a Panel as it constructor parameter. It detects the mouse wheel when the cursor is over the display area and sends the message to the panel: using System;using System.Collections.Generic;using System.Diagnostics;using System.Drawing;using System.Text;using System.Runtime.InteropServices;using System.Windows.Forms;namespace MouseWheelTest{   

After async postback, hide/show panel stops working

I have a Gridview in an UpdatePanel with a column containing an "expander" button that shows (and hides) more detail beneath its row of data.  It all works great until the user pages the gridview.  After the async postback to page the gridview, the javascript function to toggle hide/show appears to work flawlessly (the expander's button image even changes correctly), but the detail panel just doesn't show on the page.Note that my expander control supports a "AsyncTriggerId" property that, if set in the markup, will rebind the javascript toggle function when that control triggers an async postback (see OnPreRender below)Here's the hide/show toggle javascript:function toggleExpander(divId, imgId) { var div = document.getElementById(divId); var img = document.getElementById(imgId); var cssClass = div.getAttribute("className"); if (div.style.display == "" || div.style.display == "none" || cssClass == "hidden") { div.style.display = "inline"; div.setAttribute("className", ""); img.src = "images/dir_down.png"; mce_src = "images/dir_down.png"; img.alt = "Collapse to hide details"; } else { div.style.display = "none"; img.src = "images/dir_rig

How to determine if a user control is contained by the update panel that triggered async postback

Does anyone know a simple way to determine if a user control is contained in an update panel that was triggered for async postback?At the moment, the only pseudo logic for this I can think of is?'Loop through the update panel controls on the page and find the one that is involved in the postback (isInPartialRendering)'Try to find the user control as a child of the update panel

How does Twitter maintain password field on postback?


I know that for security reasons, it's generally frowned upon to try and maintain a password field on a postback, but I'd still like to figure out a way to have it done. For example, Twitter. If you try to start a new account, and let's say the username you've chosen has already been taken, the page posts back with an error. But, with Twitter, the password field does not clear. How are they doing this?

I find it annoying in a situation like this, because if the username is already taken, that means you have to go back and fill in the password field too.

How does Twitter do this?...

Color Box Jquery Not Working in Update Panel After the Initial Postback


Hi Guys,

I have an UpdatePane that contains a Listview


		<asp:LinkButton ID="lnkName" runat="server" CommandArgument='<%# Container.DisplayIndex %>'
            CommandName="SelectedRow" Text='<%# Eval("Name") %>' Class="info" Rel='<%# Eval("ID") %>' />

This linkButton will serves as the trigger to call my color box jquery. Function stated below

 <script src="script/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="script/jquery.colorbox-min.js" type="text/javascript"> </script>
    <script type="text/javascript">

        $(document).ready(function() {

            $("a.info").click(function() {

                $(this).attr("href", "EmployeeDirectoryDetail.aspx?id=" + $(this).attr("rel"));
                $(this).colorbox({ height: "200p

page inside update panel doesn't refresh the session object after postback of any control



I have many controls like dropdown, radiobuttonlist, etc on my page and I put all these controls inside the update panel so that the page doesn't look to be posting back when something is selected. Now the working on the page is very smooth. But the session object isn't getting refreshed even if I postback to the server and as a result even if the users are working on the page they are being sent to the login screen after 20 mins.

Is there anyway where I could put all the controls in update panel and still refresh the session after any postback(dropdown selection)

Any help is greatly appreciated.

Thanks in advance

Wizard Scroll Position


I have a page that contains a asp:Wizard control.

I set MaintainScrollPositionOnPostback = true for the page.

When the wizard proceeds to the next step, the scroll position from the previous step is maintained.

How can I make the scroll position to be at the top for a new step? and maintain it when it postback to to same step (like when there are validation errors).


ValidationSummary and Scroll Position



I have a form which has a number of user controls on it.  Each user control has a Validation Summary inside it, and if a user clicks on the the submit button for a particular User Control, the user control validates itself and shows errors in the Validation Summary.

The problem is that if any error show up, the page returns to the top of the page.  Is there any way of making sure that this doesn't happen?

Please don't advise me to use Page.MaintainScrollBackPosition because I already use this and this only helps when a post back occurs.  Because the validators execute on the client side, there is no post back.  I'm guessing there is a problem (?) with using ValidationSummary that causes the page to scroll up to the top of the page?

How to stop Horizontal Scroll bar on Panel?


I have a panel on a pretty basic C# page.  I've set the height, and width, and set thescrollbars = "Vertical".  However, on some pages, the panel adds a horizonal scroll bar.  It seems very random, and I can't figure out why or how to prevent the panel from adding horizontal scroll bars.   The content in the panel is dynamic from a sql database, and I use a Repeater to display the returned sql. 

 Here is my code from my page for the panel.  Did I forget something????


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