javascript - ASP DropDownList 样式设计困难

标签 javascript c# css asp.net dropdown

<分区>

有谁知道如何设置 asp 下拉列表的样式?下拉列表的箭头很难改变,这是它最初的样子:

enter image description here

有没有人有任何解决方案来修复或设置此 asp 下拉列表的样式?

这是我的代码:(我无法将其更改为选择下拉列表,因为我的下拉列表选项是根据列表框中的选择动态填充的)

Asp文件

<asp:DropDownList ID="NewDropDownList" runat="server" Width="136px" 
 OnSelectedIndexChanged="jobRun_SelectedIndexChanged" AutoPostBack="True" >  
</asp:DropDownList>

CS文件

public void BindNewDropDownList()
{
    //Lost to hold the values
    List<DateTime> listCopy = new List<DateTime>();
    DateTime dt;
    string values = String.Join(", ", JOBRUN_CBL.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Text));
    if (values.Contains("Select All"))
    {
        //Loop through each items in listbox and then add it to list
        foreach (ListItem li in ListBox1.Items)
        {
            if (DateTime.TryParse(li.Text, out dt))
            {
                listCopy.Add(dt);
            }
        }
    }
    else
    {
        //Loop through each items in listbox and then add it to list
        foreach (ListItem li in ListBox1.Items)
        {
            //check if item is selected
            if (li.Selected == true)
            {
                //add items to list
                listCopy.Add(DateTime.Parse(li.Text));
            }
        }
    }

    //compare and sort so that the latest date comes on top
    listCopy.Sort((x, y) => y.CompareTo(x));
    //clear the items in dropdownlist
    NewDropDownList.Items.Clear();
    //set the datasource to dropdownlist
    NewDropDownList.DataSource = listCopy;
    //set the dateformatstring in dropdownlist
    NewDropDownList.DataTextFormatString = "{0:dd-MMM-yyyy}";
    //Bind the dropdownlist
    NewDropDownList.DataBind();
}

请帮我解决这个问题,我已经为此寻找了很长一段时间的解决方案,但仍然找不到装饰它的方法。

谢谢。

最佳答案

您可以轻松地设置 DropDownList 的样式

这里有一些我对你有帮助的文章

https://wisdmlabs.com/blog/customize-drop-down-list-using-css/

https://css-tricks.com/dropdown-default-styling/

http://www.htmllion.com/default-select-dropdown-style-just-css.html

仅供引用,所有 ASP.NET 控件在浏览器中呈现时都会转换为 HTML 标记,因此您不需要为 DropDownList 设置任何特殊样式。您为 SELECT 元素设置的样式将适用于 DropDownList。

问候,

关于javascript - ASP DropDownList 样式设计困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33384761/

上一篇:css - 折叠的导航栏高度不同

下一篇:html - 当窗口大小改变时元素移动

相关文章:

javascript - 显示 DOM 对象内容

c# - 在 C# 中编码(marshal) IntPtr 数组

c# - 如何使用 AJAX 动态创建文本框并将其添加到占位符?

html - 我是 CSS 新手。我的背景图片未加载。我正在使用外部 CSS,我的操作系统是 Windows

css - 使用@media 忽略整个样式表

javascript - 保持窗口隐藏直到初始化完成

javascript - 如何重置 Google reCaptcha?

javascript - 在 Javascript 中仅显示浏览器版本

c# - WPF + MVVM + 单选按钮 : Handle binding with single property

javascript - raphael js 中面积图的工具提示问题