Mar 15, 2011, 10:43 AM
[FIXED] [1.0 RC1] Ext.net form fields server side events are broken.
I've found that the server side events of most form fields are broken. Looking at the source code of RC1 I see that LoadPostData is not implemented correctly (at least it seems to me). From what I understand from the MS docs it needs to return true in order to raise events.
There are probably more, I didn't bother to check every single of them. It's easy to test, just put them on a form with a button and log if the event gets triggered. The problem always occurs and it doesn't matter if it's postback, directevent or directmethod.
So there are are actually two bugs:
This is a problem for two reasons:
It is possible to work around both issues, but it is very annoying:
PS: Sorry if this is already fixed in SVN, I searched but couldn't find a relevant topic. I'm still prototyping with the RC1, but planning to buy a commercial license soon.
- Looking at TextFieldBase.cs everything is good, it compares to the old value and only returns true if it actually changed. TextField and TextArea work as expected. So this proves it can be made working :-)
- DateField.cs doesn't compare to the old value and always returns true. This has the result that OnTextChanged and OnSelectionChanged are always triggered, even if the field content didn't change at all.
- I don't know what's wrong with the checkbox, but in my test it never triggered OnCheckedChanged, even though it always returns true from LoadPostData. Some other controls have the same problem.
- MultiCombo and TimeField always trigger OnTextChanged once you entered a value, but never trigger OnValueChanged. They don't care if the selection actually changed.
There are probably more, I didn't bother to check every single of them. It's easy to test, just put them on a form with a button and log if the event gets triggered. The problem always occurs and it doesn't matter if it's postback, directevent or directmethod.
So there are are actually two bugs:
- OnChanged events not getting triggered for some controls. For example, OnValueChanged works for DateField, but OnCheckedChanged doesn't work for checkbox and radio button. If I look at the RC1 source, maybe because checkbox implements IPostBackEventHandler.RaisePostBackEvent instead of override void RaisePostDataChangedEvent like DateField? I don't know who the caller is, but if he doesn't go through the interface then that would explain it.
- LoadPostData implementations for quite a few controls don't bother to check if the value actually changed. Since also quite a few controls do check if the value changed it shouldn't be a problem to fix the broken ones?
This is a problem for two reasons:
- OnChanged events not getting triggered on some controls. It can be worked around by subscribing to OnTextChanged where available, but that's not possible for all field types (eg. checkbox and radio fields have no TextChanged event).
- Change events are triggered when the value didn't actually change. That's very annoying when you have a page where only parts of the controls are in use. For example I have cases where fields are on card layouts or tab panels and when a different panel is visible they still may trigger events.
It is possible to work around both issues, but it is very annoying:
- Use OnTextChanged where other events don't work, and for checkbox/radio button I use direct events to go right back to the server when clicking them (not so good for performance but it works).
- Manually track the previous value and ignore the event when it didn't actually change.
PS: Sorry if this is already fixed in SVN, I searched but couldn't find a relevant topic. I'm still prototyping with the RC1, but planning to buy a commercial license soon.
Last edited by Daniil; Jun 27, 2011 at 10:28 AM.
Reason: [FIXED]