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

解决方案 »

  1.   

    <%@ 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>//没有经过测试,自已试一下吧
      

  2.   

    //嗯重写一个吧
    //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) 
                            { 
                                    if(xmlHttp.status==200) 
                                    { 
                                        var Req = xmlHttp.responseText;
                                        
                                        //取<form>和</form>中间的内容
                                        var re=new RegExp(/(<form)([\s\S]+?)(>)([\s\S]+?)(<\/form>)/);
                                        if(re.test(Req))
                                            Req=RegExp.$4;                                    document.getElementById("test2Div").innerHTML=Req; 
                                    } 
                            } 
                    } 
            </script> </head>
    <body>
        <form id="form1" runat="server">
        <div>
            传递参数 :<input id="Text1" type="text" value="0" />
            <input id="Button1" type="button" value="button" onclick="GetTest2()" />
            <div id="test2Div" style="width: 280px; height: 199px; position:absolute; left: 194px; top: 82px;border:1px solid #afafaf;">
            </div>
        
        </div>
        </form>
    </body>
    </html>
    //要显示的网页
    //ajaxtest2.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AjaxTest2.aspx.cs" Inherits="Share_AjaxTest2" %><!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>
    </head><body>
        <form id="form2" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        
        </div>
        </form>
    </body>
    </html>//ajaxtest2.aspx.csusing System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class Share_AjaxTest2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["id"] == null)
                TextBox1.Text = "没有任何值传入";
            else
                TextBox1.Text = "传入了值:" + Request["id"].ToString();
        }
    }
      

  3.   

    忙着辞职换工作呢,呵呵“悲伤的西班牙”兄 是自己写了个完整的ajax示例,我搜了一下,Ajax.NET   Professional框架自己好像没提供这样的方法,看来要精细的控制页面,还是要自己写,正在学习jquery