3

I have a form in which the user can choose a component type from a combo box, and depending on that component they may or may not be able to choose a data type from another combo box.

When the user selects a component type, client-side javascript fires on the change and sets the value of the data-type combo box if required and disables the data-type combo box if required. Here's the strange thing: when that form submits the server-side gets the value of that data-type combo box and it's not what I set it to!

I've seemingly narrowed it down to one line of javascript:

document.all("cmbDataType").disabled = true;

If that line is commented out, it still gets set to the right value based on the component type but not disabled, and the form submit gives the correct value to the server based on the value that the client chooses.

If that line executes, then despite the user seeing the correct value in that disabled combo box, the value returned to the server is not correct.

I haven't been able to find anyone else with the same problem, so I hope it's not something super-weird. Browser is IE7, webapp is ASP.NET 2.0. Thanks for looking!

1 Answer 1

2

The reason this is happening is that ASP.NET 2.0 doesn't submit the values of disabled controls by default. (More accurately, it doesn't update the server control values on post back.) You can override that by putting the following line in your Page_Load event:

Page.Form.SubmitDisabledControls = true;

Or you could set the value in the form tag:

<form id="myForm" runat="server" SubmitDisabledControls="true">
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much! I never knew that tidbit, and setting that form tag value fixed it straight away!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.