在这里研究后:
我添加了在回发时保持滚动位置的功能:
<div id="pagingPanelDiv">
<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release" />
<script type="text/javascript">
// It is important to place this JavaScript code after ScriptManager1
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
if ($get('<%=pagingPanel.ClientID%>') != null) {
// Get X and Y positions of scrollbar before the partial postback
xPos = $get('<%=pagingPanel.ClientID%>').scrollLeft;
yPos = $get('<%=pagingPanel.ClientID%>').scrollTop;
}
}
function EndRequestHandler(sender, args) {
if ($get('<%=pagingPanel.ClientID%>') != null) {
// Set X and Y positions back to the scrollbar
// after partial postback
$get('<%=pagingPanel.ClientID%>').scrollLeft = xPos;
$get('<%=pagingPanel.ClientID%>').scrollTop = yPos;
}
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pagingPanel" runat="server" Height="50px" Width="1175px" ScrollBars="Horizontal" Wrap="false"></asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
问题是现在按下按钮时不会发生回发,因此按钮不会像我想要的那样更新gridview。我怎样才能解决这个问题?