Reputation: 2004
In a form the drop down list gets disabled if a checkbox is ticked. The drop down list has two options C o r D. When the drop down list gets disabled and the form is saved again it is losing the value that was selected in the drop down list and only reads in the first value.
So if I select the second option which is D and when the drop down gets disabled, I save the form again it reads in the first option which is C and overwrites the previous value saved.
I'm setting the drop down list to disabled by adding the attribute:
ddlJobType.Attributes.Add("disabled", "disabled");
I tried removing the attribute when the form is saving so it reads in the actual value selected but that didn't work:
ddlJobType.Attributes.Remove("disabled");
How can I keep the drop down list as disabled but stop losing the value?
Upvotes: 0
Views: 1433
Reputation: 2563
Is readonly
attribute can be used in your site?
Disabled controls does not get populated into post back - Disabled form inputs do not appear in the request. So backend do not know what was previously selected.
Upvotes: 1