ASP.NET:当dropdownlist选择索引更改时,阻止页面向上滚动 [英] ASP.NET: prevent page is scrolling up when dropdownlist selected index change

查看:73
本文介绍了ASP.NET:当dropdownlist选择索引更改时,阻止页面向上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET,我在一个表单中有多个下拉列表,如果我从下拉页面选择一个值滚动回来。我已经将MaintainScrollPositionOnPostBack设置为True,但同样的事情再次发生。如何阻止它跳到屏幕顶部?





谢谢

121s

解决方案

如果你只是在IE中测试这个功能它应该没有任何问题。但对于Chrome,您需要执行以下步骤:

1.右击项目。

2.点击添加 - > 添加新项目。

3.在添加新项目窗口中,选择浏览器文件,然后单击添加。



4.应用程序会要求您将此文件放在App_Browsers文件夹中,单击是

5.现在添加保持滚动位置的功能如下:



< browsers> 
< browser refid = Safari1Plus >
< capabilities>
< capability name = supportsMaintainScrollPositionOnPostback >
value = true />
< / 功能 > < / 功能 >
< / 浏览器 >
< / 浏览器 >





欲了解更多信息,请参阅以下链接

维护Chrome的滚动位置问题修复。 [ ^ ]



http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspx





并且在这里他们提到这个功能在Firefox中不常用,它已在2011年12月29日ASP.NET修复程序中修复。

http://connect.microsoft.com / VisualStudio / feedback / details / 714316 / asp-net-4-0-30319-maintaincrollpositiononpostback-now-failed-in-firefox [ ^ ]





如果你想拥有自己的定制解决方案,可以参考以下链接:



http://www.aspsnippets.com/Articles/ASPNet-MaintainScrollPositionOnPostback-not-working-in-Firefox-and-Chrome.aspx [ ^


I'm using ASP.NET, I have more than one dropdown list in a single form ,if I selected a value from dropdown page is scrolling back . I have used MaintainScrollPositionOnPostBack set to True, but the same thing happen again. How do I stop it from jumping to the top of the screen?


Thanks
121s

解决方案

if you are testing this functionality only in IE it should work without any problem. but for Chrome you need to go through the following steps :
1.Right click on the project.
2.Click on "Add" -> "Add New Item".
3.In the "Add New Item" window, select "Browser File" and click "Add".

4.Application will ask you to place this file in "App_Browsers" folder, click "Yes"
5.Now add the capability of maintaining the scroll position as follows:

 <browsers>
  <browser refid="Safari1Plus">
    <capabilities>
      <capability name="supportsMaintainScrollPositionOnPostback">
          value="true" />
    </capability></capabilities>
  </browser>
</browsers>



For more information refer to the following links
Maintain Scroll Position Problem fix for Chrome.[^]

http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspx


and also here they mentioned that this functionality didn't used to work in Firefox, it's fixed in Dec 29th 2011 ASP.NET hotfix.
http://connect.microsoft.com/VisualStudio/feedback/details/714316/asp-net-4-0-30319-maintainscrollpositiononpostback-now-fails-in-firefox[^]


if you want to have your own custom solution you can refer to the following link :

http://www.aspsnippets.com/Articles/ASPNet-MaintainScrollPositionOnPostback-not-working-in-Firefox-and-Chrome.aspx[^]


这篇关于ASP.NET:当dropdownlist选择索引更改时,阻止页面向上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆