Add support for multiple fomrs on the client side in case of TARGET_J2EE portal support.
[mono.git] / mcs / class / System.Web / resources / callback.js
index bdab5971b356621e14da4f5b8bf868a2fc132e24..789d7d12d765b84163398f5ff12a148184649853 100644 (file)
@@ -1,7 +1,8 @@
-
 function WebForm_DoCallback (id, arg, callback, ctx, errorCallback)
 {
-       var qs = WebForm_getFormData () + "&__CALLBACKTARGET=" + id + "&&__CALLBACKARGUMENT=" + escape(arg);
+       var myForm = WebForm_GetFormFromCtrl (id);
+       var qs = WebForm_getFormData (myForm) + "&__CALLBACKTARGET=" + id + "&&__CALLBACKARGUMENT=" + escape(arg);
+       // WebForm_httpPost (myForm.serverURL, qs, function (httpPost) { WebForm_ClientCallback (httpPost, ctx, callback, errorCallback); });
        WebForm_httpPost (document.URL, qs, function (httpPost) { WebForm_ClientCallback (httpPost, ctx, callback, errorCallback); });
 }
 
@@ -17,14 +18,14 @@ function WebForm_ClientCallback (httpPost, ctx, callback, errorCallback)
        callback (doc, ctx);
 }
 
-function WebForm_getFormData ()
+function WebForm_getFormData (theForm)
 {
        var qs = "";
        var len = theForm.elements.length;
        for (n=0; n<len; n++) {
                var elem = theForm.elements [n];
                if (qs.length > 0) qs += "&";
-               qs += elem.name + "=" + escape (elem.value);
+               qs += elem.name + "=" + encodeURIComponent (elem.value);
        }
        return qs;
 }
@@ -36,7 +37,6 @@ function WebForm_httpPost (url, data, callback)
        
        if (typeof XMLHttpRequest != "undefined") {
                httpPost = new XMLHttpRequest ();
-               httpPost.addEventListener ("load", function () { callback (httpPost);}, false );
        } else {
                if (axName != null)
                        httpPost = new ActiveXObject (axName);
@@ -51,8 +51,8 @@ function WebForm_httpPost (url, data, callback)
                        if (httpPost == null)
                                throw new Error ("XMLHTTP object could not be created.");
                }
-               httpPost.onreadystatechange = function () { if (httpPost.readyState == 4) callback (httpPost); };
        }
+       httpPost.onreadystatechange = function () { if (httpPost.readyState == 4) callback (httpPost); };
        
        httpPost.open ("POST", url, true);      // async
        httpPost.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");