Question

Like the title says, there is code in place that disables a few Web Controls that are placed in forms that take user input. The input is disabled in the case that I am working on as there are only viewing the data and not able to edit it.

Here is the code:

   //Disable Debtor Fields
   //dpDebtorDOB.Enabled = false;
   txtDebtorDOBYear.Enabled = false;
   ddlDebtorDOBMonth.Enabled = false;
   txtDebtorDOBDay.Enabled = false;
   txtDebtorFirstName.Enabled = false;
   txtDebtorLastName.Enabled = false;
   txtDebtorAddress1.Enabled = false;
   txtDebtorAddress2.Enabled = false;
   txtDebtorCity.Enabled = false;
   ddlDebtorProvince.Enabled = false;
   txtDebtorPostalCode.Enabled = false;
   txtDebtorPhoneNumber.Enabled = false;

   // Disable Co-Debtor Fields
   btnCopyDebtor.Visible = false;
   btnClearCoDebtor.Visible = false;
   //dpCoDebtorDOB.Enabled = false;
   txtCoDebtorDOBYear.Enabled = false;
   ddlCoDebtorDOBMonth.Enabled = false;
   txtCoDebtorDOBDay.Enabled = false;
   txtCoDebtorFirstName.Enabled = false;
   txtCoDebtorLastName.Enabled = false;
   txtCoDebtorAddress1.Enabled = false;
   txtCoDebtorAddress2.Enabled = false;
   txtCoDebtorCity.Enabled = false;
   ddlCoDebtorProvince.Enabled = false;
   txtCoDebtorPostalCode.Enabled = false;
   txtCoDebtorPhoneNumber.Enabled = false;

All of the code that is supposed to disable the Co-Debtor fields does not take effect. When I enter the worksheet that has these fields disabled, they appear to be disabled but when the page finishes loading, the fields will become editable again. Also, if I un-comment the Debtor field code above, the Co-Debtor fields are disabled and stay disabled.

If anyone has any suggestions as to what could be the problem that'd be appreciated. So far I've looked within the asp designer to see if the text boxes are sharing properties, to see if on page loads the fields are getting re-enabled in other methods and have taken a look in the JavaScript as well to see if that might be the cause of it but I have found nothing.

No correct solution

OTHER TIPS

To do it codewise you should do like you do. Example of disabling a textbox.

 TextBox t = (TextBox)ctrl;
 t.Enabled = false;

Have you looked at how the rendred page looks like in the pagesource AFTER BEING LOADED are there any attributes that say disabled?

The following elements support the disabled attribute:

  • button
  • input
  • optgroup
  • option
  • select
  • textarea

To disable a form control, add disabled="disabled" to the element. For example:

<input type="text" name="foo" value="bar" disabled="disabled" />

To re-enable the element, remove the disabled="disabled" attribute:

<input type="text" name="foo" value="bar" />

The following elements support the read-only attribute:

  • input
  • textarea

To make a form control read-only, add readonly="readonly" to the element. For example:

<input type="text" name="foo" value="bar" readonly="readonly" />

To allow the element to be written to, remove the readonly="readonly" attribute:

<input type="text" name="foo" value="bar" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top