I have recently inplemented some drop-down lists (combos) on a page where one is dynamically populated according to the selection of another using the microsoft ajax extensions. I had to set AutoPostBack = true, and enable viewstate in order for the serverside events to fire, but once this was done, all seemed well - so far so good...
Also, when the page form is submitted, the Javascript validateForm() function is executed to perform client-side validation of the form.
My problem is that now AutoPostBack is enabled, it's possible for the form to be submitted as a result of a combo click, and validateForm() is no longer being called.
So... to overcome this, I added the following in the 'Render()' of the drop-down control...
this.Attributes["onchange"] = "javascript:return validateForm();";
...now when I click on a drop-down, the whole form is validated client-side to avoid the form being submitted in an invalid state.
All this works, but my server-side event .. SelectedIndexChanged on the combo is no longer firing when validateForm() is definately returning true.
It's almost as if the addition of the onchange attribute is somehow intefering with what ajax is doing under the covers.
Does anyone know how to effectively mix client-side and server-side (ajaxed) events on a combo such that the client-side validation can be performed, and only if this returns true, would we then want the (ajaxed) server-side event to go ahead and fire? I only seem to be able to do one or the other at the moment.
Cheers
Simon.