<asp:ScriptManager ID="tsm" runat="server" ScriptMode="Release" />
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
if ($get('<%=Panel1.ClientID%>') != null) {
xPos = $get('<%=Panel1.ClientID %>').scrollLeft;
yPos = $get('<%=Panel1.ClientID %>').scrollTop;
}
}
function EndRequestHandler(sender, args) {
if ($get('<%=Panel1.ClientID%>') != null) {
$get('<%=Panel1.ClientID%>').scrollLeft = xPos;
$get('<%=Panel1.ClientID%>').scrollTop = yPos;
}
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>
Reference:
http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/
Note:
if application throw the following error,Place the script with in the body.
Error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
if ($get('<%=Panel1.ClientID%>') != null) {
xPos = $get('<%=Panel1.ClientID %>').scrollLeft;
yPos = $get('<%=Panel1.ClientID %>').scrollTop;
}
}
function EndRequestHandler(sender, args) {
if ($get('<%=Panel1.ClientID%>') != null) {
$get('<%=Panel1.ClientID%>').scrollLeft = xPos;
$get('<%=Panel1.ClientID%>').scrollTop = yPos;
}
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>
Reference:
http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/
Note:
if application throw the following error,Place the script with in the body.
Error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
No comments:
Post a Comment