Don’t name your input controls “submit”

I just discovered what happens when you name your input controls “submit”.  I have an aspx page with a button on it.  The button had an ID of “submit”.  The page also has a logout link at the top of the page, which stopped working.  After debugging for a while I realized the __doPostBack function was throwing an exception.  The code looks like:

function __doPostBack(eventTarget, eventArgument) {
  if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    theForm.__EVENTTARGET.value = eventTarget;
    theForm.__EVENTARGUMENT.value = eventArgument;
    theForm.submit();
  }
}

The error was that theForm.submit wasn’t a method.  So I set a breakpoint to check out what submit was, and it turned out to be my input button!  The one I stupidly gave an ID of “submit”.  So after a quick ID change everything started working.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s