asp.net ajax分页

来源:百度知道 编辑:UC知道 时间:2024/05/23 20:20:12
一个页面中CreatePageAjax.aspx有
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreatePageAjax.aspx.cs" Inherits="CreatePageAjax" %>
<%@ OutputCache Duration="60" VaryByParam="PageNo" %>
在另一个页面中PageShowAjax.aspx读取CreatePageAjax.aspx的输出代码,运行PageShowAjax时,xmlrequest对象创建失败。
function createXMLHttpRequest()
{
var isRight = true;
try{ xmlHttp = new XMLHttpRequest(); }
catch(trymicrosoft)
{
try{xmlHttp = new ActiveXobject("Msxml2.XMLHTTP");}
catch(othermicrosoft)
{
try{xmlHttp = new ActiveXobject("Microsoft.XMLHTTP");}
catch(failed)
{
isRight = false;
}
}
}
if(!isRight)
alert("XML对象创建失败");
}
还是有错,刚刚用ajax和json代码太多,检测不出来。要不我把源文件发个你们,你们看看吧。我qq601588935 。我刚

关於生成httprequest对象。
这段代码相信有用。
从bingo.js里抽出来的

var _httpRequest;
if (window.XMLHttpRequest){
_httpRequest = new XMLHttpRequest();
}else if (window.ActiveXObject) {
var MSXML=['MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
for(var n=0;n<MSXML.length;n++){
try {
_httpRequest=new ActiveXObject(MSXML[n]);
break;
}catch(e){}
}
}

我一般用ajax控件 没怎么用过这种方法
以前用的是这个 你看看
<script language="javascript">
function getXMLHTTPRequest()
{
var xRequest=null;
if (window.XMLHttpRequest)
{
xRequest=new XMLHttpRequest();
}
else if (typeof ActiveXObject != "undefined")
{
xRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
return