维护页面滚动位置的UpdatePanel部分回发后 [英] Maintaining page scroll position after updatepanel partial postback
问题描述
我在ASP.NET初学者,我有维护页面的滚动位置一个UpdatePanel的部分回发后一个问题。我试着在&LT设置
但它没有这样做的伎俩。请注意,我使用(并有能力使用),Firefox浏览器。 MaintainScrollPositionOnPostback =真正的
;%@页面语言=C#......%>
任何帮助将是AP preciated。谢谢!这里是我的code:
< ASP:内容ID =的BodyContentContentPlaceHolderID =日程地址搜索Maincontent=服务器>
< ASP:HiddenField ID =ClassificationHiddenField=服务器/>
< ASP:HiddenField ID =DateHiddenField=服务器/>
<表>
&所述; TR>
&所述; TD>
< ASP:面板ID =GroupTitlePanel的CssClass =titlePanelBold边框=岭=服务器
WIDTH =400像素>
<表ID =MainTable>
&所述; TR>
< TD ALIGN =中心类=节日礼物>
< ASP:标签ID =GROUPLABEL=服务器>
< / ASP:标签>
< / TD>
< TD ALIGN =中心类=都市风情>
< ASP:标签ID =ReturnLabel=服务器文本=预期收益>
< / ASP:标签>
< / TD>
< / TR>
< /表>
< / ASP:面板>
< BR />
< ASP:面板ID =GroupMainPanel=服务器WIDTH =400像素>
< / ASP:面板>
< / TD>
< TD WIDTH =100px的'>
< / TD>
&所述; TD>
< / TD>
< / TR>
< /表>
< ASP:面板ID =BottomPanel=服务器边框=岭>
<表>
&所述; TR>
< TD ALIGN =中心>
< BR />
< ASP:ToolkitScriptManager ID =ToolkitScriptManager1的EnablePartialRendering =真
=服务器>
< / ASP:ToolkitScriptManager>
< ASP:的CheckBoxList =服务器ID =GroupCheckBoxListRepeatColumns =10RepeatDirection =水平
RepeatLayout =表的AutoPostBack =真的ClientIDMode =自动识别OnSelectedIndexChanged =GroupCheckBoxList_SelectedIndexChanged>
< / ASP:&的CheckBoxList GT;
< / TD>
< / TR>
&所述; TR>
&所述; TD>
< ASP:的UpdatePanel ID =GroupUpdatePanel=服务器可见=真的UpdateMode =有条件的>
<&的ContentTemplate GT;
< ASP:面板ID =GroupGraphPanel=服务器可见=真>
< / ASP:面板>
< /&的ContentTemplate GT;
<&触发器GT;
< ASP:AsyncPostBackTrigger控件ID =GroupCheckBoxList事件名称=的SelectedIndexChanged/>
< /触发器>
< / ASP:的UpdatePanel>
< / TD>
< / TR>
< /表>
< / ASP:面板>
这看起来像回答你的问题。作为一个优先;它似乎在每个浏览器工作不只是FF。
<一个href=\"http://www.c-sharpcorner.com/Blogs/11804/maintain-scroll-position-on-postback-within-updatepanel.aspx\" rel=\"nofollow\">http://www.c-sharpcorner.com/Blogs/11804/maintain-scroll-position-on-postback-within-updatepanel.aspx
如果您使用的是IE那么它很简单,只是把code在
页面指令。
块引用>&LT;%@页面语言=C#AutoEventWireup =真
codeFILE =Default.aspx.cs继承=_默认
MaintainScrollPositionOnPostback =真正的%GT;
但它不会在Firefox工作了,你必须添加一个浏览器
文件到您的网站
右键单击解决方案资源管理>添加新项
选择浏览器文件,并将其添加到App_Browsers文件夹中。
添加MaintainScrollPositionOnPostback能力,这个浏览器文件
下面写的。
块引用>&LT;&浏览器GT;
&LT;浏览器REFID =Mozilla的&GT;
&LT;能力与GT;
&LT;功能名=supportsMaintainScrollPositionOnPostbackVALUE =真/&GT;
&LT; /能力和GT;
&LT; /浏览器&GT;
&LT; /浏览器&GT;
有些时候,这也不能正常工作,
然后一个简单的解决方案只是网后添加一个空白更新面板
和onpostback只是把焦点放在上一个更新面板将在工作
任何浏览器。
在CS postbackevent updatepanel1.Focus();
如果有任何问题只是随意问或任何修改的回复。
块引用>I am a beginner at ASP.NET and I have a problem maintaining the scroll position of the page after a partial postback of an UpdatePanel. I tried setting
MaintainScrollPositionOnPostback="true"
in<%@ Page Language="C#" ...%>
but it didn't do the trick. Please note that I am using (and have to use) FireFox.Any help would be appreciated. Thank you! Here is my code:
<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>
解决方案This looks like the answer to your question. As a plus; it appears to work on every browser not just FF.
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.
这篇关于维护页面滚动位置的UpdatePanel部分回发后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!