I've got a DropDownList
in ASP.NET that has a ListItem
that requires being disabled... but I DON'T mean Enable="False"
. And I also don't want to disable the entire DropDownList, just one specific ListItem
. What I'm talking about is written in HTML as disabled="disabled"
, like so:
<option disabled="disabled" value="-1">Disabled Option</option>
Anyone know how to do this in ASP.NET?
Have you tried adding
disabled="disabled"
on the ListItem element?Bear in mind that browser compatibility varies: http://www.lattimore.id.au/2005/06/18/disable-options-in-a-select-dropdown-element/
You could try setting the attribute from code behind, that way you can programmatically decide what value to be set.
So in your example you would do something like this: