Monday, April 26, 2010

Why don't my dynamic controls work?!

I had a bug that drove me crazy: in one of my ASP.NET pages, none of the dynamic control worked, meaning when I clicked a button, nothing happened, and the callback function wasn't called.
I suspected AJAX, but even after I removed all traces of AJAX in the page, the controls still didn't work.
I started removing code from the page, until all the code-behind file was almost empty, to no avail.
So I went to the .aspx file, and started removing controls from the page.
Until I removed one control, and suddenly my dynamic controls started working fine.
The control that caused all the problem was a required field validation.
My error was that I forgot to assign a ValidationGroup property to the validator. Since it didn't have any validation group, it got activated every time any control was clicked on the page, and caused the action to fail using client call, before any code got to the server code-behind of the page.
I hope this will save some time for another programmer with similar problem.

No comments:

Post a Comment