<分区>
<分区>
有谁知道如何设置 asp 下拉列表的样式?下拉列表的箭头很难改变,这是它最初的样子:
有没有人有任何解决方案来修复或设置此 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/