Monday, September 28, 2009

ASP.NET Dropdown Text aligment

I've tried to find solution for problem on net but I couldn't find it. What I wanted to achieve is to have some items in drop down list moved a bit more to the right.

I tried to accomplished it by adding " " at the moment when I created items but it didn't worked. Those spaces (" ") were not recognized at the moment when items were rendered. Then I tried with double non breaking spaces (  ) but those were rendered like that    in front of item's text.

At the end I've got it with:

item.Attributes.Add("style", "padding-left:10px;");


And drop down looks like on image below:



Generally speaking use attributes property whenever you need to apply some styles to items in drop down.

Cheers

No comments: