0

My ListBox on aspx page is as follows:-

 <asp:ListBox ID="ddlItems" runat="server" Style="padding: 2px; width: 210px; height:200px;">
  </asp:ListBox>

I am adding BackGround Image to my List items as

follows in code behind and its working perfectly:-

myListItem.Attributes.Add("style", "background-image:url(" + "'www.mysite.com/"  + 

"images/Gradient/" + ds.Tables[0].Rows[iGroups]

["Backgroundimage"].ToString() + "');");

Now I have tried many things but I cant get to make

the list items' font bold and White in color. Also

how can I increase the height of these list items

and hence the font size?

I have tried the following but its' not working:-

  myListItem.Attributes.Add("ForeColor", "White");
  myListItem.Attributes.Add("style", "font-weight:bold");

1 Answer 1

2

I think you should use CssClass property or set 'class' attribute instead of style, because if you're setting multiple styles, you are in fact overwriting style each time.

CssClass: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.cssclass.aspx

setting class in code behind: Adding css class through aspx code behind

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.