Maintain div or panel scroll position after postback in asp.net update panel
By default asp.net updatepanel will not maintain the div/panel scroll position after partial post back. To main the scroll position we need to add our own javascript.
Note: You need to add the below javascript code after the scriptmanager tag.
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
if ($get('divid') != null) {
xPos = $get('divid').scrollLeft;
yPos = $get('divid').scrollTop;
}
}
function EndRequestHandler(sender, args) {
if ($get('divid') != null) {
$get('divid').scrollLeft = xPos;
$get('divid').scrollTop = yPos;
}
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>
Useful Tools
Online Code Editor and Compiler
HTML Minifier
Online HTML Compiler/Preivew
Word Count Tool
Replace Text/Word tool
Latest Blogs
How to check if a canvas is empty or blank
Maintain div or panel scroll position after postback in asp.net update panel
Draggable button using jquery ui
Get total number of tables, views, stored procedures and functions count and names in sql server
JavaScript function to get date in mmddyyyy hhmmss ampm forma