asifa
asifa

Reputation: 771

how to check if a control is disabled or not?

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

Answers (2)

Rab
Rab

Reputation: 35582

if(ddlSectorRailway.Attributes["disabled"]!=null)
{
  if(ddlSectorRailway.Attributes["disabled"]=="disabled")
 {
   //your code 
 }
}

Upvotes: 2

nunespascal
nunespascal

Reputation: 17724

You should code it like this:

ddlSectorRailway.Enabled = false;

Then on save you can check:

if(ddlSectorRailway.Enabled)
{
   //save code
}

Upvotes: 3

Related Questions