【问题标题】:asp.net dropdownlist image country flagsasp.net 下拉列表图像国家标志
【发布时间】:2018-07-30 21:27:07
【问题描述】:

请看一下屏幕截图,其中 GB 标志显示为 css 测试范围,下拉列表显示没有标志图像的国家列表,我需要显示标志图像!

<span class="flag-icon flag-icon-gb"></span>

<div class="col-xs-12 col-sm-5 pl0">
<asp:DropDownList CssClass="form-control thintext" ID="lstCountryLivingIn" runat="server" ClientIDMode="Static">
<asp:ListItem Text="Please Select..." Value=""></asp:ListItem>
</asp:DropDownList>
</div>

代码隐藏

If ds.Tables(0).Rows.Count > 0 Then
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim li As New ListItem()
li.Value = ds.Tables(0).Rows(i)("CountryId").ToString
li.Text = ds.Tables(0).Rows(i)("CountryTitle").ToString & " ( " & ds.Tables(0).Rows(i)("CountryPhoneCode").ToString & " )"

‘ I need to add some css / style or attribute here to show country flags

lstCountryLivingIn.Items.Add(li)
Next

我需要在代码隐藏中使用 css / 样式来在每个下拉项目中显示国家/地区标志,但我不确定如何使用???

我在国家表中有 2 个字符的 ISO 国家代码,例如“gb”,并且我有所有 svg 格式的标志

进一步参考: http://www.aspdotnet-pools.com/2014/09/dropdownlist-item-with-custom-icon.html

【问题讨论】:

    标签: asp.net dropdown


    【解决方案1】:

    您可以在here 下载它们。根据您提到的示例链接,您可以为每个组合项设置背景图像/ css。

    编辑:我们无法通过痛苦下拉菜单来实现这一点,请参考this 问题。如果我们使用BootstrapjQuery 下拉菜单,我们可以达到同样的效果。

    【讨论】:

      猜你喜欢
      • 2011-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      • 1970-01-01
      • 1970-01-01
      • 2014-11-15
      相关资源
      最近更新 更多