本文介绍了如何给出下拉列表背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在asp.net中为我动态添加的下拉值创建了一个下拉控件。我想设置背景图片和悬停颜色所有这些东西怎么办? 我尝试过的事情: < asp:TableCell ColumnSpan =2Style =padding-left:30px; padding-bottom:20px;> < asp:DropDownList runat =serverID =ddlshopnameCssClass =PMSdropdown> DataTable dtprojects = new DataTable(); dtprojects.TableName = Project; DataColumn dcproject = new DataColumn(); dcproject.DataType = Type.GetType( System.String); dcproject.ColumnName = shopId; dtprojects.Columns.Add(dcproject); dcproject = new DataColumn(); dcproject.DataType = Type.GetType( System.String); dcproject.ColumnName = Shopname; dtprojects.Columns.Add(dcproject); DataRow drprojects = dtprojects.NewRow(); drprojects = dtprojects.NewRow(); drprojects [ shopId] = 1; drprojects [ Shopname] = Shop1; dtprojects.Rows.Add(drprojects); drprojects = dtprojects.NewRow(); drprojects [ shopId] = 2; drprojects [ Shopname] = Shop2; dtprojects.Rows.Add(drprojects); ddlshopname.DataSource = dtprojects; ddlshopname.DataTextField = Shopname; ddlshopname.DataValueField = shopId; ddlshopname.DataBind(); 解决方案 Quote:我想设置背景图像和悬停颜色。 您可以使用CSS来做到这一点。 < style type = text / css > 选项:悬停 { background-color : black; / * background-image:url(paper.gif);尚未尝试过* / 颜色 : white} < / style> 希望,它有帮助:) I created one dropdown control in asp.net for that drop down value I added dynamically. I want to set background image and hover color all those things how to do?What I have tried:<asp:TableCell ColumnSpan="2" Style="padding-left: 30px; padding-bottom: 20px;"> <asp:DropDownList runat="server" ID="ddlshopname" CssClass="PMSdropdown">DataTable dtprojects = new DataTable(); dtprojects.TableName = "Project"; DataColumn dcproject = new DataColumn(); dcproject.DataType = Type.GetType("System.String"); dcproject.ColumnName = "shopId"; dtprojects.Columns.Add(dcproject); dcproject = new DataColumn(); dcproject.DataType = Type.GetType("System.String"); dcproject.ColumnName = "Shopname"; dtprojects.Columns.Add(dcproject); DataRow drprojects = dtprojects.NewRow(); drprojects = dtprojects.NewRow(); drprojects["shopId"] = "1"; drprojects["Shopname"] = "Shop1"; dtprojects.Rows.Add(drprojects); drprojects = dtprojects.NewRow(); drprojects["shopId"] = "2"; drprojects["Shopname"] = "Shop2"; dtprojects.Rows.Add(drprojects); ddlshopname.DataSource = dtprojects; ddlshopname.DataTextField = "Shopname"; ddlshopname.DataValueField = "shopId"; ddlshopname.DataBind(); 解决方案 Quote:I want to set background image and hover color.You can use CSS to do that.<style type="text/css"> option:hover{ background-color:black; /*background-image: url("paper.gif"); haven't tried it yet*/ color:white}</style>Hope, it helps :) 这篇关于如何给出下拉列表背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 08:14