嗨,html下拉列表和列表框有什么区别?以及如何创建它? [英] Hi, What is the difference between html drop down list and list box ? and how to create it?

查看:129
本文介绍了嗨,html下拉列表和列表框有什么区别?以及如何创建它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我有一个疑问,下拉列表和列表框之间有什么区别?以及如何在html中创建这些控件.... ??



任何人都可以告诉我吗?



先谢谢.... :)


i am having one doubt,what is the difference between dropdownlist and list box ? and how to create these controls in html ....??

can any one tell me?

Thanks in Advance....:)

推荐答案

如果你使用MVC,你只需要使用帮助器......

DropDown: https:/ /msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions.dropdownlist(v=vs.118).aspx [ ^ ]

列表: https://msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions.listbox(v = vs.118).aspx [ ^ ]



如果你想了解这里读取的基础HTML:

DropDown: http://www.w3schools.com/tags/tag_select.asp [ ^ ]

列表: http://www.w3schools.com/html/html_lists.asp [ ^ ]
If you use MVC you only have to use the helpers come with...
DropDown: https://msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions.dropdownlist(v=vs.118).aspx[^]
List: https://msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions.listbox(v=vs.118).aspx[^]

If you want to learn about the underlying HTML read here:
DropDown: http://www.w3schools.com/tags/tag_select.asp[^]
List: http://www.w3schools.com/html/html_lists.asp[^]


首先,请注意关于差异的问题没有任何意义,因为这种不确定的概念通常会发生。它应该是什么意思?而不是询问差异,你只需要了解事情是如何运作的。



如果我可以从字面和正文中逐字地提出你的问题,我会忽略问题标签,因为严格来说,它们与HTML没有直接关系,问题是HTML。然后答案是:在HTML中,没有下拉框或列表框。有一个HTML元素可以扮演这样的角色,具体取决于一些选项:< select> 元素:

https://www.w3.org/wiki/HTML/Elements/select [ ^ ]。



关于班级名为 ListBox DropDownList ,它们只是使用此HTML文档的包装器。使用此类时,ASP.NET HTTP响应将使用< select> 元素生成HTML。特别是在System.Web.Mvc中,这是基于类 System.Web.Mvc.Html.SelectExtensions ,它提供了一种呈现不同形式的方法使用适当的静态方法(如工厂方法)的元素: https://msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions%28v=vs.118%29.aspx [ ^ ]。



程序集System.Web中有类似的类: https://msdn.microsoft.com/en-us/library/system。 web.ui.webcontrols.listcontrol%28v = vs.110%29.aspx [ ^ ]。



-SA
First of all, note that the question about "difference" makes no sense, as it usually happens with this uncertain concept. What would it supposed to mean? Instead of asking about "difference", you just need to understand how things work.

If I could take your question literally, from its title and body, I would have to ignored the question tags because, strictly speaking, they are not directly related to HTML, and the question is HTML. Then the answer would be: in HTML, there are not drop-down boxes or list boxes. There is one HTML element which play such roles, depending on some options: <select> element:
https://www.w3.org/wiki/HTML/Elements/select[^].

As to the classes named ListBox or DropDownList, they are just the wrappers using this HTML document. When you use such classes, the ASP.NET HTTP response generates HTML with <select> element. In particular, in "System.Web.Mvc", this is based on the class System.Web.Mvc.Html.SelectExtensions which provides a way to render different forms of this elements using appropriate static method (something like factory methods): https://msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions%28v=vs.118%29.aspx[^].

There are similar classes in the assembly "System.Web": https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol%28v=vs.110%29.aspx[^].

—SA


1。所有两个控件都是向用户显示数据的方式,因此他们可以选择它,虽然列表框同时向用户显示许多选项(按控制按钮)和让他们选择一个或多个,而Drop-down让他们只选择一个。



2。在下拉列表中如果你写多个然后它充当列表框其他明智的正常下拉菜单。





下拉列表示例



1.All two control are ways to present data to the user so they can select it, although List-box shows many options to the user simultaneously(press control button) and lets them pick one or more, whereas Drop-down lets them choose only one.

2.In drop-down if you write multiple then it act as list-box other wise normal drop-down.


Example for dropdown

<select>
  <option value="volvo">C#</option>
  <option value="saab">Asp</option>
  <option value="mercedes">Ado</option>
  <option value="audi">Mvc</option>
</select>







列表框示例






Example for listbox

<select multiple>
  <option value="volvo">C#</option>
  <option value="saab">Asp</option>
  <option value="mercedes">Ado</option>
  <option value="audi">Mvc</option>
</select>


这篇关于嗨,html下拉列表和列表框有什么区别?以及如何创建它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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