我有一个gridview放在ASP.NET面板。
面板和Gridview都在UpdatePanel中。
gridview中有一列导致部分PostBack。
我想在这些回发页面上维护面板滚动位置。
有什么办法吗
问候。
面板和Gridview都在UpdatePanel中。
gridview中有一列导致部分PostBack。
我想在这些回发页面上维护面板滚动位置。
有什么办法吗
问候。
解决方法
在asp.net中没有内置的解决方案
但是,这个问题有一个解决方法;你需要用javascript来处理它。
解决方案在这里提到:Maintain Scrollbar Position Inside UpdatePanel After Partial PostBack
2012年5月20日编辑看完评论后
<form id="form1" runat="server"> <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('<%=Panel1.ClientID%>') != null) { // Get X and Y positions of scrollbar before the partial postback xPos = $get('<%=Panel1.ClientID%>').scrollLeft; yPos = $get('<%=Panel1.ClientID%>').scrollTop; } } function EndRequestHandler(sender,args) { if ($get('<%=Panel1.ClientID%>') != null) { // Set X and Y positions back to the scrollbar // after partial postback $get('<%=Panel1.ClientID%>').scrollLeft = xPos; $get('<%=Panel1.ClientID%>').scrollTop = yPos; } } prm.add_beginRequest(BeginRequestHandler); prm.add_endRequest(EndRequestHandler); </script> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" Height="300"> <%-- Some stuff which would cause a partial postback goes here --%> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </form>
以下是代码快照:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。