日期:2014-05-18  浏览次数:20389 次

Ajax.NET Professional 如何请求一个页面


使用Ajax.NET Professional框架,如何在页面test1的一个div里显示页面test2?

------解决方案--------------------
iframe
------解决方案--------------------
UP
------解决方案--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>测试</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function GetTest2()
{
createXMLHttpRequest();
var url= "test2.aspx";
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=showResult;
xmlHttp.send(null);
}
function showResult()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
document.getElementById("test2Div).innerHTML=xmlHttp.responseText;
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center" id ="test2Div">
</div>
</form>
</body>
</html>



//没有经过测试,自已试一下吧
------解决方案--------------------
//嗯。。。重写一个吧。。。

HTML code

//ajaxtest.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AjaxTest.aspx.cs" 

Inherits="Share_AjaxTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
           <script   type="text/javascript"> 
                var   xmlHttp; 
                function   createXMLHttpRequest() 
                { 
                        if(window.ActiveXObject) 
                        { 
                                xmlHttp   =   new   ActiveXObject("Microsoft.XMLHTTP"); 
                        } 
                        else   if(window.XMLHttpRequest) 
                        { 
                                xmlHttp   =   new   XMLHttpRequest(); 
                        } 
                } 
                function   GetTest2() 
                { 
                        createXMLHttpRequest(); 
                        var id  = document.getElementById("Text1").value;
                        
                        var   url=   "ajaxtest2.aspx?id=" + id; 
                        xmlHttp.open("GET",url,true); 
                        xmlHttp.onreadystatechange=showResult; 
                        xmlHttp.send(null); 
                } 
                function   showResult() 
                { 
                       
                        if(xmlHttp.readyState==4) 
                        {