by Al Beecy
March 27, 2009
Recently I was pulling my hair out trying to figure out why a LinkButton wired up with a Telerik AjaxManager was failing to work. I had a number of similar pages and that all worked fine. The only meaningful difference was a few additional user controls.
So I began removing suspect controls one-by-one until the button began working. It turned out that the control in question made heavy use of JavaScript handlers registered in the Page_Load.
So I commented out the block of registrations and placed the control back on the page. The button still worked. After uncommenting the handlers one-by-one, the offending line was identified. The "onsubmit" handler was killing my button.
After Googling around for a while, it became clear that Ajax in general (not just Telerik’s controls) was rather finicky about sharing an event with other handlers unless everyone was voiciferously happy.
Long story short, I changed this:
Page.Form.Attributes.Add("onsubmit", "myFunction();");
to this:
Page.Form.Attributes.Add("onsubmit", "myFunction();return true;");