Link to home
Start Free TrialLog in
Avatar of josephdaviskcrm
josephdaviskcrmFlag for United States of America

asked on

ASP.NET change font size of a dropdownlist programatically

Seems like the only way to get the text size of a dropdownlist to change is by using the Font-Size="X-Small" attribute in the aspx file.  Well, I'm building some dropdownlists in my code behind file (VB) and I can't seem to find that property or any other way to alter the font size of a dropdownlist when creating one dynamically.
Dim ddl As DropDownList = New DropDownList
        ddl.ID = "RestaurantFilter"
 
        Dim li As ListItem = New ListItem
        li.Text = "View All Restaurants"
        li.Value = "all"
        li.Selected = True
        ddl.Items.Add(li)
 
        li = New ListItem
        li.Text = "View Open Restaurants Only"
        li.Value = "open"
        ddl.Items.Add(li)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of apresto
apresto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dipakdave1983
dipakdave1983

all u can do is set class of dropdown.

so it will be like this

if(condtion true)
dropdown.attributes.add('class","smooth_css"); //smooth_css is css class
else
dropdown.attributes.add('class","hard_css"); //hard_css is css class
Avatar of josephdaviskcrm

ASKER

I of course had already tried it, but when I tried it before I used font-size:8px; instead of font-size:8pt; So it didn't work.  Using 'pt' works.  Thanks.

No problem, happy to help
Apresto
try this
Dim ddl As DropDownList = New DropDownList
ddl.Font.Size = "X-Large"
You could use that, but what defines C-Large, you have alot more flexibility using CSS, stick with that :)
Apresto