I do the following in javascript on this page: http://new.boemarine.com
txtShippingStreet.SetText(txtStreetAddress.GetText());
It sets it on the screen.
But if you hit submit request it validates and the fields are blank in the shipping address if you check off same as billing after filling in your billing address.
It should keep that value and post it back but it isn't.
What am I doing wrong? Or is this a bug?
We have closed this ticket because another page addresses its subject:
ASPxTextBox ClientEnabled="false" loses value after postback
Hello James,
Thank you for your report. I have tried to replicate your issue with a small project, but was not able to. Would you please check how the attached project works? If it works well, please try to reproduce this issue using it, and send the project back to us. We will do our best to help you.
Thanks,
Marion
I've issolated the issue. When "Same as Billing" is checked, it sets the text value of the shipping controls AND it disables the shipping controls. If it doesn't disable them, then it works fine. If it does, then it fails on this line of the submit button:
if (!DevExpress.Web.ASPxEditors.ASPxEdit.ValidateEditorsInContainer(RequestInformation))
return;
(it goes into the return)
Using the immediate window, the disabled shipping controls have no value.
It should have the proper values even if they are disabled. (which is the bug)
Hello James,
Thank you for your response.
According to your post, I can assume that you need to avoid the validation of invisible controls. In this case, please use the overload of the ASPxEdit.ValidateEditorsInContainer method that takes a "validateInvisibleEditors " parameter.
If my hint does not help you, please provide us with code snippets illustrating your scenario, so that we could reproduce the issue. Alternatively, send us a working project (containing only the problematic controls) or modify our sample showing the described behavior. So we will examine it on our side and suggest you a more appropriate solution.
We will do our best to help you.
Thanks,
Jenny
You need to re-read what I wrote. It isn't anything like what you describe. I was very clear.
The controls get disabled, not made invisible.
And on the server side, the disabled control's values are not being persisted even though they should be, and thus the server side validation fails because the controls that are required fail validation.
The disabled controls that have values should have their values passed back to the server side properly.
That's the bug. It's easy to repro.
Dear James,
I apologize if my answer was incorrect or incomplete. As I understand, the txtShippingStreet control mentioned in your prior post is ASPxTextBox instead. As far as I see, the http://new.boemarine.com contains only a single ASPxTextBox:
var dxo = new ASPxClientTextBox('ctl00_txtSearch');
However, it does not seem to perform any validation. I am ready to help you resolve the described problem, but I need additional details from you.
Could you please clarify whether or not your scenario is: The ASPxTextBox.ClientEnabled property is set to false via the ASPxClientTextBox.SetEnabled method? After that, this ASPxTextBox is validated on the server side in the ASPxButton.Click event handler via the ASPxEdit.ValidateEditorsInContainer method.
We would appreciate it if you could provide a screencast to illustrate the issue. For example, you can capture it using a free Jing tool from TechSmith.
We will do our best to find a solution for your inquiry.
Thanks,
Jenny
Here's the exact definition of the control:
<dxe:ASPxTextBox ID="txtShippingStreet" runat="server" Width="250px" MaxLength="150" EnableClientSideAPI="true" ClientInstanceName="txtShippingStreet">
<ValidationSettings>
<RequiredField IsRequired="true" ErrorText="Please enter a street address" />
</ValidationSettings>
</dxe:ASPxTextBox>
Absolutely requires entry.
It's text is set like this: txtShippingStreet.SetText(txtStreetAddress.GetText());
And it's enabled is set like this: txtShippingStreet.SetEnabled(!chkSame.GetChecked());
On post back, when this is done, the server side does not get the value of the txtShippingStreet.Text property (it's empty) and thus validation fails as it should.
The control should be returning the value it has for the text property even when disabled.
Hello James,
Thank you for your clarification. I have discussed the described scenario with our developers. When you submit a form to the server, the "disabled" inputs value is not posted. If a control is disabled, its value should not be changed in any way. Otherwise, it should be enabled. Such behavior is common for our controls. Please take a look at the ASPxTextBox ClientEnabled="false" loses value after postback thread where we discussed a similar question in detail.
It is possible to use the ASPxHiddenField control to pass values of disabled editors to the server as a workaround.
Since in your scenario the disabled ASPxTextBox.Text property is equal to the enabled ASPxTextBox, it is possible to validate the enabled editor value and avoid sending duplicate data to the server.
We apologize for not being helpful this time. If you have any other questions, please contact us at any time.
Thanks,
Jenny
That's just silly. I should be able to get the current value of the fields any time I want just like I would be able to with the default textbox control and any winforms controls.
Disabled means that it's disabled for the end user. It doesn't mean that it's disabled for use to the developer, which is what you've done.
Again, just silly. Please fix what is obviously a bug.
Dear James,
We understand your position and concerns caused by this behavior. Still, we do not agree that it is a bug. The ASPxClientEditBase.SetEnabled method manipulates the standard HTML <input> "disabled" attribute. HTML elements with the "disabled" attribute set to "false" do not pass its values to the server. Please take a look at the Disabled controls section of the W3C forms Standard article, which states that a disabled control "cannot receive user input nor will its value be submitted with the form" .
At the same time, I should underscore that this behavior differs for different browsers. As Mike explained in Q276621 (ASPxTextBox ClientEnabled="false" loses value after postback): For the FireFox and WebKits browsers, the disabled="disabled" attribute is used to prevent an editor from being used. When you submit a form to the server, the value of a "disabled" input is not posted.
We have created a simple project with a standard input and our ASPxTextBox to illustrate this specific in action. You can notice that both editors operate the same way and do not pass their text to the server. We have also created a screencast illustrating our explanation and a debugging page by using the Firebug tool.
Your understanding is highly appreciated.
Thanks,
Jenny
See Also:
ASPxTextBox - When an editor is disabled on the client side, its Text is cleared after a postback