如何改变列表框的asp.net中选定的颜色 [英] how to change the selected color of listbox in asp.net
本文介绍了如何改变列表框的asp.net中选定的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:ListBox
ID="ddlPA"
ClientIDMode="Static"
runat="server"
AutoPostBack="true"
SkinID="x"
CssClass="ListBoxCssClass"
SelectionMode="Multiple"
OnSelectedIndexChanged="ddlPA_SelectedIndexChanged">
</asp:ListBox>
当我选择ASP项目:列表框,选择的项目颜色变为灰色,我想改变颜色为蓝色。
我怎么可以这样做?
When i select an item in asp:listbox , the selected item color changes to gray, i want to change the color to blue. how can i do the same?
推荐答案
您可以通过指定CssClass属性,或者背景色属性设置在.aspx页面中的背景颜色..它看起来像:
You can set background colors from the .aspx page by specifying either the CssClass, or the BackColor property.. it looks like:
<asp:ListBox CssClass="MyListBox" BackColor="#e0e0e0"></asp:ListBox>
设置所选的项目是有点麻烦...我不相信这是直接针对于此的属性。你可以将其设置成JavaScript或jQuery的,是这样的:
Setting the selected item is a little trickier... I don't believe there is an attribute for this directly. You can set it in javascript, or jQuery, something like:
<script type="text/javascript">
$(document).ready(function() {
$('#MyListBox').click(function() {
$("#MyListBox option:selected").css("background-color", "#e0e0e0");
});
});
</script>
这篇关于如何改变列表框的asp.net中选定的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文