问题是这样的:
我做了一个aspx页面(是根据数据库查询出来的内容动态生成的),
在首页有一个按钮,点击这个按钮可显示一个层,层里有LINK,按钮若干
我现在想通过这些LINK和按钮把参数传给aspx页面,并在这个弹出的层把页面内容显示出来
别人说用innerHTML,可是我怎么试都试不出来,请问各位高手有什么好的建议,或其他更好的方法
急啊,请大家帮帮忙,谢谢拉

解决方案 »

  1.   

    aspx页面
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    <!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>
    <title> new document </title>
    <meta name="generator" content="editplus" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    </head>
    <body>
    <form id="form2" runat="server">
        <asp:DataList ID="gllist" runat="server" RepeatColumns="3">
             <ItemTemplate>
                    <table>
                           <tr>
                              <td width="140"><a href="#">
                                    <asp:Label runat="server" ID="lbbalkhName1" Text='<%# Eval("balkhName") %>'></asp:Label></a>&nbsp;
                                           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <asp:Label runat="server" ID="Label1" Text='<%# Eval("eateryCount") %>'></asp:Label>家餐厅
                              </td>
                           </tr>
                   </table>
             </ItemTemplate>
        </asp:DataList></form>
    </body>
    </html>
    -----------------------
    aspx.cs
    -----------------------
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.Sql;
    using System.Data.SqlClient;public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
            if (!Page.IsPostBack)
            {
                string area = Request.QueryString["areaCode"];//查询条件“地区”
                string py = Request.QueryString["letter"];//查询条件“首字母”
                DataSet ds = new DataSet();
                if (!IsPostBack) {
                    if (py.Equals(""))
                    {
                        ds = AjaxMethod.Getbalkh(area);
                        gllist.DataSource = ds;
                        gllist.DataBind();
                    }
                    else
                    {                    ds = AjaxMethod.Getbalkh(area, py);
                        gllist.DataSource = ds;
                        gllist.DataBind();                }       
                }
            }
        }
    }
    -------------------
    AjaxMethod.cs
    -------------------
        //根据地区和拼音获取楼盘
            public static DataSet Getbalkh(string area,string py)
            {
                return ds;
            }
            //根据地区获取楼盘
            public static DataSet Getbalkh(string area)
            {
              return ds;
            }
    --------------------
    首页代码太多就不贴了,我现在是点击层上的按钮用JS把值放进隐藏文本域里,然后调用JS方法
    var curLetter = null;
                function getB(){
                    var curAreaCode=document.getElementById('hfAreaName').value;
                    var letter=document.getElementById('hfpy').value;
                var reqUrl = "\Default2.aspx?pagecache=1&t="+new Date();
                if (null != curAreaCode && 0 != curAreaCode) {
                reqUrl += "&areaCode=" + curAreaCode;
                }
                if (null != letter) {
                 reqUrl += "&letter=" + letter;
                curLetter = letter;
                }else{
                curLetter = null;
                }
                Ajax.doGet(reqUrl,null,districtBuild);
                }            function districtBuild(responseStr){
                var objouter=document.getElementById("showB");
                if (responseStr!=""){
                
                var objcontent=document.getElementById("showB");
                objcontent.innerHTML=responseStr;
                if(curLetter==null){
                curLetter = null;
                }else{
            
                }
                }
                else{
            objouter.style.display="none";
                }
                
                }
    把ASPX页面放进层里,可是js老出错,所以才想请各位高手帮忙看下,也许有比这个方法更好的也请各位大大提示
      

  2.   

    也可用XML异步请求
    http://www.cnblogs.com/chy710/archive/2007/04/15/713868.html
      

  3.   

    晕了,用了
    旋风的方法感觉方向是对了,就是又出错了
    function getB(){
                    var curAreaCode=document.getElementById('hfAreaName').value;
                    var letter=document.getElementById('hfpy').value;
                var reqUrl = "\Default2.aspx?pagecache=1&t="+new Date();
                if (null != curAreaCode && 0 != curAreaCode) {
                reqUrl += "&areaCode=" + curAreaCode;
                }
                if (null != letter) {
                 reqUrl += "&letter=" + letter;
                curLetter = letter;
                }else{
                curLetter = null;
                }
                Ajax.doGet(reqUrl,null,creatReq);
                }            
                 var req; //定义变量,用来创建xmlhttprequest对象
            function creatReq(reqUrl) // 创建xmlhttprequest,ajax开始
            {
                var url=reqUrl; //要请求的服务端地址
                if(window.XMLHttpRequest) //非IE浏览器,用xmlhttprequest对象创建
                {
                    req=new XMLHttpRequest();
                }
                else if(window.ActiveXObject) //IE浏览器用activexobject对象创建
                {
                    req=new ActiveXObject("Microsoft.XMLHttp");
                }
                
                if(req) //成功创建xmlhttprequest               
                {
                    req.open("GET",url,true); //与服务端建立连接(请求方式post或get,地址,true表示异步)
                     ------(在这里出现了错误,有数据的情况下,跳出"Microsoft JScript 运行时错误: 没有权限",
                                没数据跳出一个对话框,"bad request",对这个不太懂能否再知道小弟一下)-------------
                    req.onreadystatechange = callback; //指定回调函数
                    req.send(null); //发送请求
                }
            }
            function callback() //回调函数,对服务端的响应处理,监视response状态
            {
                if(req.readystate==4) //请求状态为4表示成功
                {
                    if(req.status==200) //http状态200表示OK
                    {
                        Dispaly(); //所有状态成功,执行此函数,显示数据
                    }
                    else //http返回状态失败
                    {
                        alert("服务端返回状态" + req.statusText);
                    }
                }
                else //请求状态还没有成功,页面等待
                {
                    document .getElementById ("showB").innerHTML ="数据加载中";
                }
            }
            
            function Dispaly() //接受服务端返回的数据,对其进行显示
            {
                document .getElementById ("showB").innerHTML =req.responseText;
            }
      

  4.   

    前面那个解决了
    document .getElementById ("showB").innerHTML =req.responseText; 出现“htmlfile: 未知的运行时错误”
    是什么错误
      

  5.   

    <!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>
    <title> new document </title>
    <meta name="generator" content="editplus" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    </head>
    <body>
    <form id="form2" runat="server">
        <asp:DataList ID="gllist" runat="server" RepeatColumns="3">
             <ItemTemplate>
                    <table>
                           <tr>
                              <td width="140"><a href="#">
                                    <asp:Label runat="server" ID="lbbalkhName1" Text='<%# Eval("balkhName") %>'></asp:Label></a>&nbsp;
                                           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <asp:Label runat="server" ID="Label1" Text='<%# Eval("eateryCount") %>'></asp:Label>家餐厅
                              </td>
                           </tr>
                   </table>
             </ItemTemplate>
        </asp:DataList></form>
    </body>
    </html>
    页面是这样的,有问题吗???
    要怎么解决呢,谁帮我一下谢拉 ,最后一个问题了,马上给分