In a ASP.NET form there are two textbox controls. One control set today's date and another control initially disabled. Based on date enable the control (disabled property). If date is current date, disable the textbox, else enable the control. It worked well.
Now the date is not today and text box is enabled. But when click the button, the form is posted back and the text box is disabled again. I didn't set enable/disable setting in any other places in javascript and code behind. I am not sure why this is happening.
if (condition)
{
$('#txt').prop('disabled', true); }
else
{
$('#txt').prop('disabled', false);
}
If anyone faced this kind of issue and any solution available, please help me to resolve this.
disabledproperty is not persisted/recreated in the postback. You need to re-apply (or regenerate in the HTML directly) - easiest way is to move yourif (condition)to its own function and call it on both change (as it is now I assume) and also on doc.ready:$(function() { if (condition)...(but in a separate function so it's not "DRY") - freedomn-m