c# - ListItem Background is not working on Chrome -
i want make image drop down in asp.net
worked correctly in firefox
, not working in ie
, chrome
. what's wrong code? searched in internet , tried many codes still it's not working.
<body> <form id="form1" runat="server"> <div> <asp:dropdownlist id="drop" runat="server" width="100px"/> </div> </form> </body>
and in .cs file
protected void page_load(object sender, eventargs e) { loading(); } string imageurl; private void loading() { list<string> img = new list<string>() { "canada", "usa", "england", "spain", "india" }; drop.datasource = img; drop.databind(); (int = 0; < drop.items.count; i++) { switch (drop.items[i].text) { case "india": imageurl = "images/india.png"; break; case "usa": imageurl = "images/usa.png"; break; case "england": imageurl = "/images/england.png"; break; case "canada": imageurl = "/images/canada.png"; break; case "spain": imageurl = "/images/spain.png"; break; } drop.enableviewstate = true; drop.appenddatabounditems = true; listitem item = drop.items[i]; item.attributes["style"] = "background: url(" + imageurl + ") no-repeat"; } }
Comments
Post a Comment