Reputation: 771
I have a dropdown which is disabled on certain values and enabled on certain values. During save I want to check if it is disabled or not.
I am disabling the dropdown in the following way:
ddlSectorRailway.Attributes.Add("disabled","disabled");
How to check if the dropdown is disabled or not? I want to save the dropdown value only if it is enabled. How to do this in C#?
Thanks,
Upvotes: 0
Views: 3893
Reputation: 35582
if(ddlSectorRailway.Attributes["disabled"]!=null)
{
if(ddlSectorRailway.Attributes["disabled"]=="disabled")
{
//your code
}
}
Upvotes: 2
Reputation: 17724
You should code it like this:
ddlSectorRailway.Enabled = false;
Then on save you can check:
if(ddlSectorRailway.Enabled)
{
//save code
}
Upvotes: 3