Thursday, February 9, 2012

Enabling Disabling an Asp Label(which works in Chrome/firefox/IE) Without Using .disabled in JavaScript

Enabling and Disabling a label(sounds crazy right because Label has no functionality but still you will see that requirement from Business quite often)

So here we Go:-

By now You would have noticed that if you use below the label shows as disabled in IE but not in chrome and Firefox:
document.getElementById(CityLabel).disabled = true;

I use a way which worked for me across all browsers( and since we are not causing a post back or something on Label click) so we can USE css here to do our Job

document.getElementById(CityLabel).style.color = "#666";

(above will show the label as Grey or disabled in all browsers and that is what I needed)