ASP.NET:如何创建一个onfocus显示listItens的下拉列表!!! [英] ASP.NET: how to create a dropdownlist that onfocus show a listItens!!!!

查看:106
本文介绍了ASP.NET:如何创建一个onfocus显示listItens的下拉列表!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我吗?

我想制作一个下拉列表,重点显示您的列表列表.:thumbsup:
简单! =)

改善..

我的dropDownList已填充...

我想模仿动作,请单击DropDrownList ...显示项目...但我想在焦点事件中做到这一点.

现在清楚了吗? :cool:

can anyone help me?

i wanna a make a dropdownlist that on focus shows your listItens!:thumbsup:
easy! =)

improve..

my dropDownList already populated...

i wanna imitate the action click on DropDrownList... show the items... but i wanna make this in the event on focus.

is it clear now!? :cool:

推荐答案

威廉席尔瓦(William Silva)写道:
William Silva wrote:

我想模仿动作点击在DropDrownList上...显示项目...但我想在焦点事件中做到这一点

i wanna imitate the action click on DropDrownList... show the items... but i wanna make this in the event on focus


您要尝试的是展开/打开下拉列表,并使其焦点上显示其项目,而不是单击它.

这样,显示/扩展列表不是提供的功能,因此无法完成.尽管有一种解决方法,但如果结果可以接受,则可以使用.

解决方法:
1.获取下拉列表中显示的项目总数(用N表示).
2.现在,重点关注一个JavaScript函数,该函数将下拉列表的大小"从1更改为N

像这样的东西:


What you are trying is to expand/open the dropdownlist and show its items on focus itself instead of clicking it.

As such, this showing/expanding the list is not a feature provided and cannot be done. Though there is a workaround to it which can be used if the result is acceptable.

Workaround:
1. Get the total number of items shown in the dropdown (lets say N).
2. Now on focus, call a JavaScript function that will change the ''size'' of the dropdown from 1 to N

Something like:

<select id="mySelect" runat="server"  onfocusin="Open_Dropdownlist()" onfocusout="Close_Dropdownlist()">


function Open_Dropdownlist()
{
document.getElementById("mySelect").size=N;
}
function Close_Dropdownlist()
{
document.getElementBById("mySelect").size=1;
}


您应该查找jQuery.加载页面后加载列表项将需要某种形式的回调.
You should look up jQuery. Loading your list items once the pages are loaded is going to require a callback of some form.


这篇关于ASP.NET:如何创建一个onfocus显示listItens的下拉列表!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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