Page.Form.Attributes.Add onsubmit AJAX Problem

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;");

Tags: , ,

AJAX | Asp.Net | JavaScript | Telerik

Comments

April 18, 2009 #

DotNetKicks.com

Trackback from DotNetKicks.com

Page.Form.Attributes.Add onsubmit AJAX Problem

DotNetKicks.com

April 18, 2009 #

Web Development Community

Trackback from Web Development Community

Page.Form.Attributes.Add onsubmit AJAX Problem

Web Development Community

June 14, 2009 #

DotNetShoutout

Page.Form.Attributes.Add onsubmit AJAX Problem

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout

Powered by BlogEngine.NET1.5.0.7 | Theme by Mads Kristensen