- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
资料 :
var countries = new Dictionary<string,string>();
countries.Add("AF","Afghanistan");
countries.Add("US","United States");
countries.Add("FR","France");
@Html.DropdownList("Countries",new SelectList(countries, "key", "value", "US"), "Select Country")
"US"
对于 selectedValue 和
"Select Country"
对于选项标签。我希望这会插入
"Select Country"
作为下拉列表中的第一项,并且有
"US"
已经为我选择了。
"Select Country"
已插入,但
"US"
未选中。
"Select Country"
是。
"Please Select"
, 但也预选
"US"
作为默认值?
最佳答案
对于寻找国家/地区列表的人,这将有所帮助
var countries = new[]
{
new SelectListItem { Value = "AF", Text = "AFGHANISTAN"},
new SelectListItem { Value = "AX", Text = "ÅLAND ISLANDS"},
new SelectListItem { Value = "AL", Text = "ALBANIA"},
new SelectListItem { Value = "DZ", Text = "ALGERIA"},
new SelectListItem { Value = "AS", Text = "AMERICAN SAMOA"},
new SelectListItem { Value = "AD", Text = "ANDORRA"},
new SelectListItem { Value = "AO", Text = "ANGOLA"},
new SelectListItem { Value = "AI", Text = "ANGUILLA"},
new SelectListItem { Value = "AQ", Text = "ANTARCTICA"},
new SelectListItem { Value = "AG", Text = "ANTIGUA AND BARBUDA"},
new SelectListItem { Value = "AR", Text = "ARGENTINA"},
new SelectListItem { Value = "AM", Text = "ARMENIA"},
new SelectListItem { Value = "AW", Text = "ARUBA"},
new SelectListItem { Value = "AU", Text = "AUSTRALIA"},
new SelectListItem { Value = "AT", Text = "AUSTRIA"},
new SelectListItem { Value = "AZ", Text = "AZERBAIJAN"},
new SelectListItem { Value = "BS", Text = "BAHAMAS"},
new SelectListItem { Value = "BH", Text = "BAHRAIN"},
new SelectListItem { Value = "BD", Text = "BANGLADESH"},
new SelectListItem { Value = "BB", Text = "BARBADOS"},
new SelectListItem { Value = "BY", Text = "BELARUS"},
new SelectListItem { Value = "BE", Text = "BELGIUM"},
new SelectListItem { Value = "BZ", Text = "BELIZE"},
new SelectListItem { Value = "BJ", Text = "BENIN"},
new SelectListItem { Value = "BM", Text = "BERMUDA"},
new SelectListItem { Value = "BT", Text = "BHUTAN"},
new SelectListItem { Value = "BO", Text = "BOLIVIA, PLURINATIONAL STATE OF"},
new SelectListItem { Value = "BQ", Text = "BONAIRE, SINT EUSTATIUS AND SABA"},
new SelectListItem { Value = "BA", Text = "BOSNIA AND HERZEGOVINA"},
new SelectListItem { Value = "BW", Text = "BOTSWANA"},
new SelectListItem { Value = "BV", Text = "BOUVET ISLAND"},
new SelectListItem { Value = "BR", Text = "BRAZIL"},
new SelectListItem { Value = "IO", Text = "BRITISH INDIAN OCEAN TERRITORY"},
new SelectListItem { Value = "BN", Text = "BRUNEI DARUSSALAM"},
new SelectListItem { Value = "BG", Text = "BULGARIA"},
new SelectListItem { Value = "BF", Text = "BURKINA FASO"},
new SelectListItem { Value = "BI", Text = "BURUNDI"},
new SelectListItem { Value = "KH", Text = "CAMBODIA"},
new SelectListItem { Value = "CM", Text = "CAMEROON"},
new SelectListItem { Value = "CA", Text = "CANADA"},
new SelectListItem { Value = "CV", Text = "CAPE VERDE"},
new SelectListItem { Value = "KY", Text = "CAYMAN ISLANDS"},
new SelectListItem { Value = "CF", Text = "CENTRAL AFRICAN REPUBLIC"},
new SelectListItem { Value = "TD", Text = "CHAD"},
new SelectListItem { Value = "CL", Text = "CHILE"},
new SelectListItem { Value = "CN", Text = "CHINA"},
new SelectListItem { Value = "CX", Text = "CHRISTMAS ISLAND"},
new SelectListItem { Value = "CC", Text = "COCOS (KEELING) ISLANDS"},
new SelectListItem { Value = "CO", Text = "COLOMBIA"},
new SelectListItem { Value = "KM", Text = "COMOROS"},
new SelectListItem { Value = "CG", Text = "CONGO"},
new SelectListItem { Value = "CD", Text = "CONGO, THE DEMOCRATIC REPUBLIC OF THE"},
new SelectListItem { Value = "CK", Text = "COOK ISLANDS"},
new SelectListItem { Value = "CR", Text = "COSTA RICA"},
new SelectListItem { Value = "CI", Text = "CÔTE D'IVOIRE"},
new SelectListItem { Value = "HR", Text = "CROATIA"},
new SelectListItem { Value = "CU", Text = "CUBA"},
new SelectListItem { Value = "CW", Text = "CURAÇAO"},
new SelectListItem { Value = "CY", Text = "CYPRUS"},
new SelectListItem { Value = "CZ", Text = "CZECH REPUBLIC"},
new SelectListItem { Value = "DK", Text = "DENMARK"},
new SelectListItem { Value = "DJ", Text = "DJIBOUTI"},
new SelectListItem { Value = "DM", Text = "DOMINICA"},
new SelectListItem { Value = "DO", Text = "DOMINICAN REPUBLIC"},
new SelectListItem { Value = "EC", Text = "ECUADOR"},
new SelectListItem { Value = "EG", Text = "EGYPT"},
new SelectListItem { Value = "SV", Text = "EL SALVADOR"},
new SelectListItem { Value = "GQ", Text = "EQUATORIAL GUINEA"},
new SelectListItem { Value = "ER", Text = "ERITREA"},
new SelectListItem { Value = "EE", Text = "ESTONIA"},
new SelectListItem { Value = "ET", Text = "ETHIOPIA"},
new SelectListItem { Value = "FK", Text = "FALKLAND ISLANDS (MALVINAS)"},
new SelectListItem { Value = "FO", Text = "FAROE ISLANDS"},
new SelectListItem { Value = "FJ", Text = "FIJI"},
new SelectListItem { Value = "FI", Text = "FINLAND"},
new SelectListItem { Value = "FR", Text = "FRANCE"},
new SelectListItem { Value = "GF", Text = "FRENCH GUIANA"},
new SelectListItem { Value = "PF", Text = "FRENCH POLYNESIA"},
new SelectListItem { Value = "TF", Text = "FRENCH SOUTHERN TERRITORIES"},
new SelectListItem { Value = "GA", Text = "GABON"},
new SelectListItem { Value = "GM", Text = "GAMBIA"},
new SelectListItem { Value = "GE", Text = "GEORGIA"},
new SelectListItem { Value = "DE", Text = "GERMANY"},
new SelectListItem { Value = "GH", Text = "GHANA"},
new SelectListItem { Value = "GI", Text = "GIBRALTAR"},
new SelectListItem { Value = "GR", Text = "GREECE"},
new SelectListItem { Value = "GL", Text = "GREENLAND"},
new SelectListItem { Value = "GD", Text = "GRENADA"},
new SelectListItem { Value = "GP", Text = "GUADELOUPE"},
new SelectListItem { Value = "GU", Text = "GUAM"},
new SelectListItem { Value = "GT", Text = "GUATEMALA"},
new SelectListItem { Value = "GG", Text = "GUERNSEY"},
new SelectListItem { Value = "GN", Text = "GUINEA"},
new SelectListItem { Value = "GW", Text = "GUINEA-BISSAU"},
new SelectListItem { Value = "GY", Text = "GUYANA"},
new SelectListItem { Value = "HT", Text = "HAITI"},
new SelectListItem { Value = "HM", Text = "HEARD ISLAND AND MCDONALD ISLANDS"},
new SelectListItem { Value = "VA", Text = "HOLY SEE (VATICAN CITY STATE)"},
new SelectListItem { Value = "HN", Text = "HONDURAS"},
new SelectListItem { Value = "HK", Text = "HONG KONG"},
new SelectListItem { Value = "HU", Text = "HUNGARY"},
new SelectListItem { Value = "IS", Text = "ICELAND"},
new SelectListItem { Value = "IN", Text = "INDIA"},
new SelectListItem { Value = "ID", Text = "INDONESIA"},
new SelectListItem { Value = "IR", Text = "IRAN, ISLAMIC REPUBLIC OF"},
new SelectListItem { Value = "IQ", Text = "IRAQ"},
new SelectListItem { Value = "IE", Text = "IRELAND"},
new SelectListItem { Value = "IM", Text = "ISLE OF MAN"},
new SelectListItem { Value = "IL", Text = "ISRAEL"},
new SelectListItem { Value = "IT", Text = "ITALY"},
new SelectListItem { Value = "JM", Text = "JAMAICA"},
new SelectListItem { Value = "JP", Text = "JAPAN"},
new SelectListItem { Value = "JE", Text = "JERSEY"},
new SelectListItem { Value = "JO", Text = "JORDAN"},
new SelectListItem { Value = "KZ", Text = "KAZAKHSTAN"},
new SelectListItem { Value = "KE", Text = "KENYA"},
new SelectListItem { Value = "KI", Text = "KIRIBATI"},
new SelectListItem { Value = "KP", Text = "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF"},
new SelectListItem { Value = "KR", Text = "KOREA, REPUBLIC OF"},
new SelectListItem { Value = "KW", Text = "KUWAIT"},
new SelectListItem { Value = "KG", Text = "KYRGYZSTAN"},
new SelectListItem { Value = "LA", Text = "LAO PEOPLE'S DEMOCRATIC REPUBLIC"},
new SelectListItem { Value = "LV", Text = "LATVIA"},
new SelectListItem { Value = "LB", Text = "LEBANON"},
new SelectListItem { Value = "LS", Text = "LESOTHO"},
new SelectListItem { Value = "LR", Text = "LIBERIA"},
new SelectListItem { Value = "LY", Text = "LIBYA"},
new SelectListItem { Value = "LI", Text = "LIECHTENSTEIN"},
new SelectListItem { Value = "LT", Text = "LITHUANIA"},
new SelectListItem { Value = "LU", Text = "LUXEMBOURG"},
new SelectListItem { Value = "MO", Text = "MACAO"},
new SelectListItem { Value = "MK", Text = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF"},
new SelectListItem { Value = "MG", Text = "MADAGASCAR"},
new SelectListItem { Value = "MW", Text = "MALAWI"},
new SelectListItem { Value = "MY", Text = "MALAYSIA"},
new SelectListItem { Value = "MV", Text = "MALDIVES"},
new SelectListItem { Value = "ML", Text = "MALI"},
new SelectListItem { Value = "MT", Text = "MALTA"},
new SelectListItem { Value = "MH", Text = "MARSHALL ISLANDS"},
new SelectListItem { Value = "MQ", Text = "MARTINIQUE"},
new SelectListItem { Value = "MR", Text = "MAURITANIA"},
new SelectListItem { Value = "MU", Text = "MAURITIUS"},
new SelectListItem { Value = "YT", Text = "MAYOTTE"},
new SelectListItem { Value = "MX", Text = "MEXICO"},
new SelectListItem { Value = "FM", Text = "MICRONESIA, FEDERATED STATES OF"},
new SelectListItem { Value = "MD", Text = "MOLDOVA, REPUBLIC OF"},
new SelectListItem { Value = "MC", Text = "MONACO"},
new SelectListItem { Value = "MN", Text = "MONGOLIA"},
new SelectListItem { Value = "ME", Text = "MONTENEGRO"},
new SelectListItem { Value = "MS", Text = "MONTSERRAT"},
new SelectListItem { Value = "MA", Text = "MOROCCO"},
new SelectListItem { Value = "MZ", Text = "MOZAMBIQUE"},
new SelectListItem { Value = "MM", Text = "MYANMAR"},
new SelectListItem { Value = "NA", Text = "NAMIBIA"},
new SelectListItem { Value = "NR", Text = "NAURU"},
new SelectListItem { Value = "NP", Text = "NEPAL"},
new SelectListItem { Value = "NL", Text = "NETHERLANDS"},
new SelectListItem { Value = "NC", Text = "NEW CALEDONIA"},
new SelectListItem { Value = "NZ", Text = "NEW ZEALAND"},
new SelectListItem { Value = "NI", Text = "NICARAGUA"},
new SelectListItem { Value = "NE", Text = "NIGER"},
new SelectListItem { Value = "NG", Text = "NIGERIA"},
new SelectListItem { Value = "NU", Text = "NIUE"},
new SelectListItem { Value = "NF", Text = "NORFOLK ISLAND"},
new SelectListItem { Value = "MP", Text = "NORTHERN MARIANA ISLANDS"},
new SelectListItem { Value = "NO", Text = "NORWAY"},
new SelectListItem { Value = "OM", Text = "OMAN"},
new SelectListItem { Value = "PK", Text = "PAKISTAN"},
new SelectListItem { Value = "PW", Text = "PALAU"},
new SelectListItem { Value = "PS", Text = "PALESTINIAN TERRITORY, OCCUPIED"},
new SelectListItem { Value = "PA", Text = "PANAMA"},
new SelectListItem { Value = "PG", Text = "PAPUA NEW GUINEA"},
new SelectListItem { Value = "PY", Text = "PARAGUAY"},
new SelectListItem { Value = "PE", Text = "PERU"},
new SelectListItem { Value = "PH", Text = "PHILIPPINES"},
new SelectListItem { Value = "PN", Text = "PITCAIRN"},
new SelectListItem { Value = "PL", Text = "POLAND"},
new SelectListItem { Value = "PT", Text = "PORTUGAL"},
new SelectListItem { Value = "PR", Text = "PUERTO RICO"},
new SelectListItem { Value = "QA", Text = "QATAR"},
new SelectListItem { Value = "RE", Text = "RÉUNION"},
new SelectListItem { Value = "RO", Text = "ROMANIA"},
new SelectListItem { Value = "RU", Text = "RUSSIAN FEDERATION"},
new SelectListItem { Value = "RW", Text = "RWANDA"},
new SelectListItem { Value = "BL", Text = "SAINT BARTHÉLEMY"},
new SelectListItem { Value = "SH", Text = "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA"},
new SelectListItem { Value = "KN", Text = "SAINT KITTS AND NEVIS"},
new SelectListItem { Value = "LC", Text = "SAINT LUCIA"},
new SelectListItem { Value = "MF", Text = "SAINT MARTIN (FRENCH PART)"},
new SelectListItem { Value = "PM", Text = "SAINT PIERRE AND MIQUELON"},
new SelectListItem { Value = "VC", Text = "SAINT VINCENT AND THE GRENADINES"},
new SelectListItem { Value = "WS", Text = "SAMOA"},
new SelectListItem { Value = "SM", Text = "SAN MARINO"},
new SelectListItem { Value = "ST", Text = "SAO TOME AND PRINCIPE"},
new SelectListItem { Value = "SA", Text = "SAUDI ARABIA"},
new SelectListItem { Value = "SN", Text = "SENEGAL"},
new SelectListItem { Value = "RS", Text = "SERBIA"},
new SelectListItem { Value = "SC", Text = "SEYCHELLES"},
new SelectListItem { Value = "SL", Text = "SIERRA LEONE"},
new SelectListItem { Value = "SG", Text = "SINGAPORE"},
new SelectListItem { Value = "SX", Text = "SINT MAARTEN (DUTCH PART)"},
new SelectListItem { Value = "SK", Text = "SLOVAKIA"},
new SelectListItem { Value = "SI", Text = "SLOVENIA"},
new SelectListItem { Value = "SB", Text = "SOLOMON ISLANDS"},
new SelectListItem { Value = "SO", Text = "SOMALIA"},
new SelectListItem { Value = "ZA", Text = "SOUTH AFRICA"},
new SelectListItem { Value = "GS", Text = "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"},
new SelectListItem { Value = "SS", Text = "SOUTH SUDAN"},
new SelectListItem { Value = "ES", Text = "SPAIN"},
new SelectListItem { Value = "LK", Text = "SRI LANKA"},
new SelectListItem { Value = "SD", Text = "SUDAN"},
new SelectListItem { Value = "SR", Text = "SURINAME"},
new SelectListItem { Value = "SJ", Text = "SVALBARD AND JAN MAYEN"},
new SelectListItem { Value = "SZ", Text = "SWAZILAND"},
new SelectListItem { Value = "SE", Text = "SWEDEN"},
new SelectListItem { Value = "CH", Text = "SWITZERLAND"},
new SelectListItem { Value = "SY", Text = "SYRIAN ARAB REPUBLIC"},
new SelectListItem { Value = "TW", Text = "TAIWAN, PROVINCE OF CHINA"},
new SelectListItem { Value = "TJ", Text = "TAJIKISTAN"},
new SelectListItem { Value = "TZ", Text = "TANZANIA, UNITED REPUBLIC OF"},
new SelectListItem { Value = "TH", Text = "THAILAND"},
new SelectListItem { Value = "TL", Text = "TIMOR-LESTE"},
new SelectListItem { Value = "TG", Text = "TOGO"},
new SelectListItem { Value = "TK", Text = "TOKELAU"},
new SelectListItem { Value = "TO", Text = "TONGA"},
new SelectListItem { Value = "TT", Text = "TRINIDAD AND TOBAGO"},
new SelectListItem { Value = "TN", Text = "TUNISIA"},
new SelectListItem { Value = "TR", Text = "TURKEY"},
new SelectListItem { Value = "TM", Text = "TURKMENISTAN"},
new SelectListItem { Value = "TC", Text = "TURKS AND CAICOS ISLANDS"},
new SelectListItem { Value = "TV", Text = "TUVALU"},
new SelectListItem { Value = "UG", Text = "UGANDA"},
new SelectListItem { Value = "UA", Text = "UKRAINE"},
new SelectListItem { Value = "AE", Text = "UNITED ARAB EMIRATES"},
new SelectListItem { Value = "GB", Text = "UNITED KINGDOM"},
new SelectListItem { Value = "US", Text = "UNITED STATES"},
new SelectListItem { Value = "UM", Text = "UNITED STATES MINOR OUTLYING ISLANDS"},
new SelectListItem { Value = "UY", Text = "URUGUAY"},
new SelectListItem { Value = "UZ", Text = "UZBEKISTAN"},
new SelectListItem { Value = "VU", Text = "VANUATU"},
new SelectListItem { Value = "VE", Text = "VENEZUELA, BOLIVARIAN REPUBLIC OF"},
new SelectListItem { Value = "VN", Text = "VIET NAM"},
new SelectListItem { Value = "VG", Text = "VIRGIN ISLANDS, BRITISH"},
new SelectListItem { Value = "VI", Text = "VIRGIN ISLANDS, U.S."},
new SelectListItem { Value = "WF", Text = "WALLIS AND FUTUNA"},
new SelectListItem { Value = "EH", Text = "WESTERN SAHARA"},
new SelectListItem { Value = "YE", Text = "YEMEN"},
new SelectListItem { Value = "ZM", Text = "ZAMBIA"},
new SelectListItem { Value = "ZW", Text = "ZIMBABWE"},
};
关于razor Html.DropdownList 提供 "Please select"作为 optionLabel 和 "US"作为 selectedValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9036457/
我的应用程序中有一些漫长的过程,因此我创建了一个WAIT PLEASE表单,然后在另一个线程上调用,如下所示: public void ShowWait() { continu
public class Qn { static class Friend { private final String name; public Friend
我正在尝试在 Excel VBA 中创建请稍候消息。这是为了提醒处理 SQL 查询的用户该过程仍在进行中。我希望将此消息显示在用户表单中。 当前,用户连接到 SQL DB,选择数据库和一些其他选项,按
我正在尝试整理来自不同媒体的报道相同故事的新闻文章,我正在使用 news-please python 库。以下代码使用给定的 URL 为我提供新闻,但我想获取多篇新闻文章(基于特定日期或日期范围)。有
我有一个严重的问题:我已经下载了最新版本的 NLTK我得到了一个奇怪的 POS 输出: import nltk import re sample_text="start please with me"
提交此 JSP 时,应要求用户选择除“请选择”之外的其他内容。如果用户选择“请选择”并提交表单,它应该通过弹出窗口提醒用户应该更改该字段。 Please Select
我有一个包含 HTML 表单的页面,一旦用户单击返回的搜索结果列表中的链接,该表单就会提交回自身。一旦他们点击链接,页面就会获取提交的变量,在各种外部 API 上运行一堆搜索,解析一堆数据,并将一堆东
我有一个很长的任务,并且在执行过程中显示“请等待”消息。我使用 SwingWorker 来实现。但有时长任务并不长,所以我想延迟 1 秒显示消息,但我不知道该怎么做。 SwingWorker mySw
我有一个通过 .net Web 服务检查用户名可用性的 Activity ,我需要在调用期间显示“请稍候”消息,因为它可能需要一两秒钟 - 我已经尝试过 AsyncTask 和 Threading,但
我有以下 3 个表: storage ( id, client, cost, -- which have no values col_1, -- which have no values col_2,
我想添加“请选择...”作为组合框中的第一个选项。请参阅下面的代码 - 有什么建议吗? 问候,彼得 "; $sql[0] = 'Please select...'; while ($row = mys
我的表单将运行一些可能需要一段时间才能执行的代码。我想在后台运行操作时显示“请稍候”消息。 我想将该消息保存在一种形式中,我可以从其他形式控制它的可见性以及它的文本。 我还希望将其设置为在 Progr
我想模拟friendlyARM的板子,Mini2440或者mini6410,这样我就可以练习嵌入式编程,QT编程等等,由于一些经济困难和奇怪的进口政策,我的国家。 无论如何,问题是我似乎无法理解进行仿
我有以下 jQuery 函数,它会在用户水平滚动超过 500 像素时触发 aTestEvent(): jQuery(document).scroll(function(){ if(jQuery
我有应用服务器,我使用 Chef + 一些临时 bash 脚本一起引导它们。问题是,当我想在这些应用程序服务器之一上运行更新时,我得到: 19:00:28: *** Please tell me wh
我有这个bootstrap-table数据表,加载完所有数据后,消息继续显示。任何人都知道为什么会这样?提前谢谢你。 Id
我需要在应用程序启动,动画启动以及应用程序更改可见性的生命周期中创建一个“请稍候”窗口。我不想创建明确的新线程(可能是ThreadPool或BackgroundWorker)。 有任何想法吗? 最佳答
我正在使用3rd party库,该库的某些功能需要很长时间才能执行,因此我想在功能繁忙时显示“请稍候”对话框。 通常我会做这样的事情: Thread longTask = new Thread (ne
我想让我的选择器在启动时显示“默认选项”。这意味着:类似“请选择一个选项”。 我尝试使用此短语手动添加选项,但是,这样在选择其他选项后可以重新选择“默认选项”,就像它是真正的选项之一一样。有什么办法可
我一直在努力制作一个模态表单来通知用户等待作业结束。这是我正在尝试做的一个简单示例: unit Unit1; interface uses Winapi.Windows, Winapi.Messa
我是一名优秀的程序员,十分优秀!