Insights and discoveries
from deep in the weeds

Tuesday, March 29, 2011

Fix for "Error in function Sys$WebForms$PageRequestManager$_matchesParentIDInList"

Have you ever found yourself confounded by a javascript error when using ASP.NET ScriptManager (e.g., UpdatePanels)?

The error occurs in ScriptManager.axd:

// Name:        MicrosoftAjaxWebForms.debug.js
// Assembly:    System.Web.Extensions
// Version:
// FileVersion: 4.0.30319.225

In this function, at line 1101:

function Sys$WebForms$PageRequestManager$_matchesParentIDInList(clientID, parentIDList) {
        for (var i = 0, l = parentIDList.length; i < l; i++) {
            if (clientID.startsWith(parentIDList[i] + "_")) {
                return true;
        return false;
There's a good explanation of the problem in this thread and a workaround for the MooTools conflict here. But I wasn't using MooTools. I'm using jQuery. As it turns out, though, in my situation it had nothing to do with jQuery. I had an input field like this:

<input id=​"uploadForm_id" type=​"hidden" name=​"id" value>

Since this is an upload form, it's outside the regular "form". And it just happens to be named "id". So, somewhere in that maze of Microsoft logic, they are taking a value of things with a "name" property called  "id", even when they shouldn't be. (The risks of duck-typing).

Changing the name to something other than ID fixed it in my case. As did overriding the prototype for this type of DOM element so that there was a definition for startsWith, which might be necessary if you were dealing with a form you couldn't change.

HTMLInputElement.prototype.startsWith = function () { return false; };

No comments:

Post a Comment