I have an asp.net web form with several textboxes, buttons, and other controls. One of the buttons is supposed to trigger validation of content in some of the textboxes. This works fine, except that if validation fails, all subsequent postbacks of the page are prevented. Fixing the invalid values gets rid of the error messages, but postback still does not occur.
The validation is occurring within an AJAX UpdatePanel. I'm not sure if that matters or not.
Best Answer
I'm glad the workaround is fine for you, but for the benefit of others who land this page, disabling client side validation is far from an acceptable solution. So here goes:
Why it happened only when
UpdatePanel
was around, is still unclear to me, however:As others have mentioned, the issue you were having is most likely because the unsuccessful validation attempt is preventing a further postback.
See also: Why won't my form post back after validation?
There is a variable called
Page_BlockSubmit
which is set to true when client side validation fails:So when a
__doPostBack
occurs as part of, say, anOnSelectedIndexChanged
of aDropDownList
, there is this check:Which will block the first time, but then clear the flag, so the next postback attempt should work.
The workaround, in my case, for a
DropDownList
'sOnSelectedIndexChanged
event, was to have a snippet added to its client-sideonchange
event:You might get away with putting that snippet into the
onchange
itself.