asp.net – 设置值时页面移位 – 我的代码或最新版本的Chrome中
在我解释我的问题之前的一些背景信息.这不会发生在任何其他测试的浏览器(IE,FireFox,Safari,甚至旧版本的chrome)中,但就在上周我和我们的几个最终用户chrome自动更新到版本:
版本38.0.2125.111 m 我开始接到电话和电子邮件,我写了一个应用程序,当它最初加载一些页面加载,页面滚动到底部,中间,而其他页面都很好. 我决定今天花更多的时间在它上面,我最初做的是找出它发生在哪个页面,因为它没有发生在我的所有aspx页面上.然后它发生的那些我想找到它们之间的共同点. 来看看我的页面加载事件中发生了什么我加载了一些初始下拉列表/列表框值.现在,在加载它之后,在其中一个列表框中,我将其设置为初始值,就像这样简单: .lbCustomers.Items.FindByValue( “SomeDefault”)选定= TRUE; 在页面完全加载chrome之后,无论页面上的控件是何处,都会将您带到控件所在页面的那一部分.几乎就像是把重点放在控制上.我可以通过将焦点放在页面顶部的某个控件上来轻松地修复/破解这个但是这感觉不对. 所以想象一下你在页面上有一大堆下拉控件,实际上你有很多页面需要你垂直滚动.如果我设置说最后一个下拉控件(位于页面底部),页面将加载并将转到页面底部.然后我查看了它将打开到页面中间的页面,当然,我正在使用默认值分配位于页面中间的控件. 这是一个使用jquery的asp.net web表单项目,我们也使用所选的库…任何人都可以在最新版本的chrome中确认这个,或者我只是做错了什么?我所做的只是设置一个下拉列表或列表框值: myDropDown.Items.FindByValue( “1”)选定=真. Chrome会直接在我设置此下拉/列表框的位置打开页面. 更新 经过进一步测试,我继续创建了一个测试aspx页面,其中包含一个下拉列表和一个列表框.我也都应用了所选的库.看起来设置下拉框通常可以正常工作.但是,当我加载并选择列表框时,问题就在这里.所以我决定尝试一个普通的列表框(没有选择应用)……同样的事情. 因此,这个问题似乎与列表框有关(如果您使用所选的库,或者您只是使用标准的aspx列表框,则无论如何).无论何时在代码后面设置列表框,它都会将页面移动到该列表框控件所在的位置. 作为测试 今天早上我创建了一个简单的aspx页面测试. >我添加的一个控件是标准的asp.net下拉列表 当我为任何下拉列表设置所选值时(无论是标准的还是选择的),正常页面加载发生,它正确地加载到顶部. 当我为任何列表框设置所选值时(无论我使用选择列表框还是标准列表框),这里都会出现问题.该页面将加载到该位置 测试我跑 只需将一些文本(很多文本)和一个列表框控件添加到aspx页面,如下所示: The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stickThe brown fox jumped over the candle stick The brown fox jumped over the candle stick The brown fox jumped over the candle stick <br/><br/><br/> <asp:ListBox ID="ListBox1" runat="server"> <asp:ListItem>1</asp:ListItem> </asp:ListBox> 现在在你的页面加载事件中放入: protected void Page_Load(object sender,EventArgs e) { if (!Page.IsPostBack) { ListBox1.Items.FindByValue("1").Selected = true; } } 在Chrome版本38.0.2125.111 m中打开此页面,您是否看到同样的问题?在IE或firefox中打开工作正常.在以前版本的chrome中打开工作正常,它只有这个版本38.0.2125.111 m. 有人可以复制吗? 解决方法
很明显,问题在于Chrome,而不是ASP.NET,因为它可以使用以下HTML文档进行复制:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>ListBox Test</title> </head> <body> <p style="margin-bottom: 200em;">Name: <input type="text"></p> <select size="5"> <option selected value="A">Apple</option> </select> </body> </html> 作为一种变通方法,您可以将自动对焦属性放在较早的输入字段上(如果有): <p style="margin-bottom: 200em;">Name: <input type="text" autofocus></p> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- CompTIA PK0-003 认证
- asp.net – 验证摘要问题
- asp.net-mvc – ASP.NET MVC 4 – @Section中Javascript函数
- asp.net – 如何从URL抓取.aspx页面名称?
- asp.net-mvc – 以表格形式上传图片并在MVC 4上显示
- asp.net-mvc – 如何将包含动态内容的包添加到asp.net Web优
- asp.net-mvc – MVC 4从基本路由中删除“home”
- asp.net – 创建新的实体数据模型的麻烦
- asp.net-core – 为什么Bind属性似乎破坏了我对嵌套对象的模
- asp.net-mvc – 在ASP.NET MVC视图中递归
- asp.net-mvc – asp.net mvc禁用ajax缓存
- asp.net-web-api – 请求的资源不支持http方法“
- asp.net-web-api – ASP.NET WebAPI支持每种方法
- asp.net-mvc – WebApi – 请求包含实体主体但没
- asp.net-web-api – 将属性注入Web API的`System
- ASP.NET – 在屏幕底部显示应用程序生成日期/信息
- asp.net-mvc – C#Razor Forms – 插入角度属性
- asp.net – IIS 8.0中内核模式和用户模式缓存之间
- asp.net-web-api – 在WebAPI中的TaskScheduler.
- asp.net-mvc – 输出字符串里的字符串文字引用