答案 0 :(得分:2)
您必须在页面指令
处设置MaintainScrollPositionOnPostback="true"
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" %>
答案 1 :(得分:0)
你必须使用javascript ..
window.onload = function() {
var objDiv = document.getElementById("<%=pnl.ClientID%>");
objDiv.scrollTop = objDiv.scrollHeight;
}
这是带有您的要求的示例aspx文件..并且它的工作正常
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
window.onload = function() {
var objDiv = document.getElementById("<%=pnl.ClientID %>");
objDiv.scrollTop = objDiv.scrollHeight;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="pnl" runat ="server" Height="200" Width="100%" ScrollBars ="vertical">
<table border="1" >
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
<tr><td>this is testing</td></tr>
</table>
</asp:Panel>
</form>
</body>
</html>