Question

EXAMPLE

<asp:TextBox ID="txbx" runat="Server" Text="1" Enabled="false" />
  1. A textbox with value '1' is set to disabled.

  2. The texbox value is updated to '2' using javascript.

  3. When posted to the server the intial value '1' is used.

I have tried overwriting this functionality with the following VB Code:

Page.Form.SubmitDisabledControls = True

QUESTION

Why doesn't the updated value post to the server?

NOTES

The updated value post correctly '2' if enabled="true"

<asp:TextBox ID="txbx" runat="Server" Text="1" Enabled="true" />
Was it helpful?

Solution

Actually what happens is if you set Enabled = false for some ASP control, that particular control will rendered on client-side but its class will be set as "aspNetDisabled" which prevents its value to be edited. I found no way to edit/change this class. So, you can't edit its value using any client-side script like JavaScript.

When you try to post its value back to server, the initial value is used which was there in server.

If you enable the control, it gets rendered and in that case you can access/edit its value as you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top