gpt4 book ai didi

c# - 在更新面板部分回发后保持页面滚动位置

转载 作者:行者123 更新时间:2023-11-30 14:56:06 24 4
gpt4 key购买 nike

我是 ASP.NET 的初学者,在 UpdatePanel 的部分回发后,我无法保持页面的滚动位置。我尝试设置 MaintainScrollPositionOnPostback="true"<%@ Page Language="C#" ...%>但它没有成功。请注意,我正在使用(并且必须使用)FireFox。

如有任何帮助,我们将不胜感激。谢谢你!这是我的代码:

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:HiddenField ID="ClassificationHiddenField" runat="server" />
<asp:HiddenField ID="DateHiddenField" runat="server" />
<table>
<tr>
<td>
<asp:Panel ID="GroupTitlePanel" CssClass="titlePanelBold" BorderStyle="Ridge" runat="server"
Width="400px">
<table id="MainTable">
<tr>
<td align="center" class="style3">
<asp:Label ID="GroupLabel" runat="server">
</asp:Label>
</td>
<td align="center" class="style4">
<asp:Label ID="ReturnLabel" runat="server" Text="Expected Return">
</asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<br />
<asp:Panel ID="GroupMainPanel" runat="server" Width="400px">
</asp:Panel>
</td>
<td width='100px'>
</td>
<td>
</td>
</tr>
</table>
<asp:Panel ID="BottomPanel" runat="server" BorderStyle="Ridge">
<table>
<tr>
<td align="center">
<br />
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" EnablePartialRendering="true"
runat="server">
</asp:ToolkitScriptManager>
<asp:CheckBoxList runat="server" ID="GroupCheckBoxList" RepeatColumns="10" RepeatDirection="Horizontal"
RepeatLayout="Table" AutoPostBack="true" ClientIDMode="AutoID" OnSelectedIndexChanged="GroupCheckBoxList_SelectedIndexChanged">
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="GroupUpdatePanel" runat="server" Visible="true" UpdateMode="conditional">
<ContentTemplate>
<asp:Panel ID="GroupGraphPanel" runat="server" Visible="true">
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GroupCheckBoxList" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</asp:Panel>

最佳答案

这看起来像是您问题的答案。作为一个加号;它似乎适用于所有浏览器,而不仅仅是 FF。

http://www.c-sharpcorner.com/Blogs/11804/maintain-scroll-position-on-postback-within-updatepanel.aspx

if you are using IE then its very simple just put the code in your page directive.

<%@ Page Language="C#" AutoEventWireup="true" 
CodeFile="Default.aspx.cs" Inherits="_Default"
MaintainScrollPositionOnPostback="true" %>

but it will not work in Firefox for that you have to add one browser file into your website

Right click on solution explorer > Add New Item

Select Browser File and add it to App_Browsers folder.

Add MaintainScrollPositionOnPostback capability to this browser file as written below.

<browsers>
<browser refID="Mozilla">
<capabilities>
<capability name="supportsMaintainScrollPositionOnPostback" value="true" />
</capabilities>
</browser>
</browsers>

Some times this also not work,

Then a simple solution just add a blank Update panel after the grid and onpostback just put the focus to that update panel it will work in any browser. in cs postbackevent updatepanel1.Focus();

If any problem just feel free to ask or any modification reply.

关于c# - 在更新面板部分回发后保持页面滚动位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23836917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com