为什么ASP.NET DropDownList控件需要在Internet Explorer中展开两次点击 [英] Why does an ASP.NET DropDownList control requires two clicks to expand in Internet Explorer

查看:295
本文介绍了为什么ASP.NET DropDownList控件需要在Internet Explorer中展开两次点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET DropDownList控件,呈现到一个下拉列表(选择HTML标签)在页面上。由于某种原因,当我在Internet Explorer中时,需要两次点击才能打开它并查看选项,这只是最终用户的一个额外的点击。它在谷歌Chrome浏览器,Mozilla Firefox和Safari工作正常 - 我只需要点击一次查看选择的选项。为什么它不能在IE中正常工作?更重要的是,我如何在IE中修复它?

I have an ASP.NET DropDownList control that renders into a dropdown list (select HTML tag) on a page. For some reason, when I'm in Internet Explorer, it requires two clicks for me to open it up and see the options, which is just an extra click for the end-user. It works fine in Google Chrome, Mozilla Firefox and Safari--I only have to click once to see the options for a selection. Why would it not work correctly in IE? And more importantly, how can I fix it in IE?

这里是我的代码:

< asp :DropDownList id =DDLClientNamerunat =serverEnableViewState =FalseAutoPostBack =Trueclass =InputFieldonfocus =Change(this,event)onblur =Change(this,event) p>

<asp:DropDownList id="DDLClientName" runat="server" EnableViewState="False" AutoPostBack="True" class="InputField" onfocus="Change(this, event)" onblur="Change(this, event)">

推荐答案

不得不删除硬编码的onfocus事件。 IE处理焦点事件的第一次点击,第二次展开下拉列表。我想这是一个已知的奇怪与IE以及其他400多个怪癖。

Had to remove the hard-coded onfocus event. IE handles the first click for the focus event, and the second to expand the dropdown. I guess this is a known quirk with IE along with the other 400+ quirks.

我仍然试图找出一种方法来改变下拉的焦点。根据你在这个回调匿名函数中输入的代码,您可能仍需要在IE中点击两次下拉菜单。我发现你可以猴子与其他控件,在这个函数内,它不需要两次点击。我会保持这个答案现在。我猜是因为微软我们不能使用onfocus在下拉列表。我可以尝试使用实际的选择标记,而不是使用Microsoft的ASP.NET DropDownList,看看是否可以使用onfocus事件,然后,没有额外的点击。我怀疑它。

I am still trying to figure out a way to change styles of the dropdown on focus. Depending on what code you put into this callback anonymous function, you may still need to click the dropdown twice in IE. I've found that you can monkey with other controls, inside this function and it doesn't require two clicks. I'll keep this as the answer for now. I guess because of Microsoft we can't use the onfocus at all on dropdowns. I may try using an actual select tag rather than using Microsoft's ASP.NET DropDownList, and see if I can use the onfocus event then, without the extra click. I doubt it.

jQuery(this.Elements.DDLClientName).focus(function(){
.. put code here
});

jQuery(this.Elements.DDLClientName).focus(function() { .. put code here });

这篇关于为什么ASP.NET DropDownList控件需要在Internet Explorer中展开两次点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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