|
var __callbackObject = new Object();
function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback) {
re = new RegExp("\\x2B", "g");
if (__nonMSDOMBrowser) {
var xmlRequest = new XMLHttpRequest();
postData = __theFormPostData +
"__CALLBACKID=" + eventTarget +
"&__CALLBACKPARAM=" + escape(eventArgument).replace(re, "%2B");
if (pageUrl.indexOf("?") != -1) {
xmlRequest.open("GET", pageUrl + "&" + postData, false);
}
else {
xmlRequest.open("GET", pageUrl + "?" + postData, false);
}
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(null);
try
{
response = xmlRequest.responseText;
if (eventCallback != null)
eventCallback(response, context);
}
catch(e)
{
if (errorCallback != null)
errorCallback(e.message, context);
}
}
else {
var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
xmlRequest.onreadystatechange = WebForm_CallbackComplete;
__callbackObject.xmlRequest = xmlRequest;
__callbackObject.eventTarget = eventTarget;
__callbackObject.eventCallback = eventCallback;
__callbackObject.context = context;
__callbackObject.errorCallback = errorCallback;
postData = __theFormPostData +
"__CALLBACKID=" + eventTarget +
"&__CALLBACKPARAM=" + escape(eventArgument).replace(re, "%2B");
usePost = false;
if (pageUrl.length + postData.length + 1 > 2067) {
usePost = true;
}
if (usePost) {
xmlRequest.open("POST", pageUrl, true);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(postData);
}
else {
if (pageUrl.indexOf("?") != -1) {
xmlRequest.open("GET", pageUrl + "&" + postData, true);
}
else {
xmlRequest.open("GET", pageUrl + "?" + postData, true);
}
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send();
}
}
}
function WebForm_CallbackComplete()
{
if (__callbackObject.xmlRequest.readyState == 4)
{
try
{
response = __callbackObject.xmlRequest.responseText;
status = __callbackObject.xmlRequest.getResponseHeader("__CALLBACKSTATUS");
if (status == "200")
{
if (__callbackObject.eventCallback != null)
__callbackObject.eventCallback(response, __callbackObject.context);
}
else
{
if (__callbackObject.errorCallback != null)
__callbackObject.errorCallback(response, __callbackObject.context);
}
}
catch(e)
{
if (__callbackObject.errorCallback != null)
__callbackObject.errorCallback(e.message, __callbackObject.context);
else
{
// For Testing Purposes
//alert(e.message);
}
}
}
}
var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
var pageUrl = "";
var __theFormPostData = "";
function WebForm_InitCallback(cbUrl) {
pageUrl = cbUrl;
var theForm = document.forms[0];
count = theForm.elements.length;
var element;
re = new RegExp("\\x2B", "g");
for (i = 0; i < count; i++) {
element = theForm.elements[i];
if (element.tagName.toLowerCase() == "input") {
__theFormPostData += element.name + "=" + element.value.replace(re, "%2B") + "&";
}
else if (element.tagName.toLowerCase() == "select") {
selectCount = element.children.length;
for (j = 0; j < selectCount; j++) {
selectChild = element.children[j];
if ((selectChild.tagName.toLowerCase() == "option") && (selectChild.selected == true)) {
__theFormPostData += element.name + "=" + selectChild.value.replace(re, "%2B") + "&";
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Elvin Cheng is currently living in Woodlands, Singapore. He has been developing applications with the .NET Framework, using C# and ASP.NET since October 2002. Elvin specializes in building Real-time monitoring and tracking information system for Semi-conductor manufacturing industry. During his spare time, he enjoys reading books, watching movie and gym.