1//------------------------------------------------------------------------------------------------------------------------------------------------ 2function CallbackPage_ExecuteAsyncCallback(serverFunction, clientFunction) { 3 4 //Set the hidden CallbackPage ReturnValue control current flag to true so we know what hidden control to get the 5 //return value from after the async callback returns a value: 6 document.getElementById("hidCallbackPage_ReturnValue").setAttribute("currentflag", "1"); 7 8 //HtmlEncode the serverFunction arg or ASP.NET will consider it a security violation due to the column delimiters and 9 //then we must URL Encode the string since HtmlEncode will put in "&" characters which are part of a url: 10 serverFunction = Callback_Escape(Callback_HtmlEncode(serverFunction)); 11 12 //Instantiate the browser specific XmlHttp object: 13 var xmlHttp = Callback_CreateXmlHttpObject(); 14 15 //Open an Asynchronous post to the current page and set the request header: 16 xmlHttp.open("POST", document.location.href, true); 17 xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 18 19 //Set the Xml object's OnReadyStateChange handler will will wait for the Aysnc request to return a value: 20 xmlHttp.onreadystatechange = function() { 21 22 if (xmlHttp.readyState == 4) { 23 24 //Set the returnValue: 25 var returnValue = ""; 26 var xmlHttpException = null; 27 if (xmlHttp.status == 200) { 28 29 returnValue = xmlHttp.responseText; 30 31 } 32 else { 33 34 //NOTE: Most of these exceptions are caused by server timeouts or other server unexpected server issues, 35 //the default server timeout in ASP.NET is 120 seconds, but the developer can extend this in the 36 //site's web.config: 37 returnValue = null; 38 xmlHttpException = xmlHttp.statusText; 39 40 } 41 42 //Finally, trigger the client side callback handler function passed by the developer: 43 CallbackPage_Internal_GetReturnValue(returnValue, clientFunction, xmlHttpException); 44 45 } 46 47 }; 48 49 //Send the callback async method to the server which will be executed via reflection: 50 xmlHttp.send("InenviXmlHttpCallbackMethod=" + serverFunction + "&ClassType=Page"); 51 52} 53//------------------------------------------------------------------------------------------------------------------------------------------------ 54function CallbackPage_Internal_GetReturnValue(returnValue, clientFunction, xmlHttpException) { 55 56 //Check the xmlHttpException to see if its not null, if so, then an unhandled exception occured so we need 57 //to pass it to the ClientFunction and then its up to the developer to check for its presence as it will only 58 //be there if an unhandled xmlHttpException occurred (for example, a server timeout is the most frequent cause: 59 if (xmlHttpException == null) { 60 61 document.getElementById("hidCallbackPage_ReturnValue").value = returnValue; 62 eval(clientFunction + "();"); 63 64 } 65 else { 66 67 document.getElementById("hidCallbackPage_ReturnValue").value = ""; //Set the return value to an empty string 68 eval(clientFunction + "(\"" + xmlHttpException + "\");"); 69 70 } 71 72} 73//------------------------------------------------------------------------------------------------------------------------------------------------
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.