当前页面currentPage.aspx中点击按钮,将currentPage.aspx上的lblCategoryID传到弹出的dialog.aspx页面(dialog.aspx这个页面是弹出窗口的样式,比较小,)。关闭dialog.aspx时将上面的ddlProduct的值给带回currentPage.aspx页面上去。简而言之,就是两个页面相互传递值的问题,并且都是aspx页面,并且都要读取后台的数据库。求助。

解决方案 »

  1.   

    采用opener这种方式
    如A打开B,那B要取得A的数据
    window.opener.document.getElementById("对象").value相反,返回也一样。
      

  2.   

    var a=document.getElementById("lbl").InnerText;
     URL = "dialog.aspx?s" + a;
    myleft = (screen.availWidth - 500) / 2;
    window.open(URL, "read_comment", "height=500,width=550,status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,top=100,left=" + myleft + ",resizable=yes");
    dialog.aspx
    window.opener.document.getElementById("textbox1")value="";
      

  3.   

    楼主先做个简单的实验,理解了就可以应用到知己的程序中!如:
    currentPage.aspx页面代码:
    <input type="text" id="Text1" /> <%--这是接受dialog.aspx返回值,今后改成隐藏域--%>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="打开页面" />currentPage.aspx C#代码:
        protected void Button1_Click(object sender, EventArgs e)
        {
            string lblCategoryID="10";
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", " window.showModalDialog('dialog.aspx?cId=" + lblCategoryID + "',document.getElementById('Text1'));", true);
        }dialog.aspx页面代码:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <base target="_self" /> <%--这句必须要有--%>
    </head>
    <body>
        <form id="form1" runat="server">
        <input type="text" id="Text2" runat="server"/> <%--返回值,今后改成隐藏域--%>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="关闭页面" />
        </form>
    </body>
    </html>dialog.aspx C#代码:
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(Request.QueryString["cId"].ToString());//接受currentPage.aspx值
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Text2.Value = "我的返回值";
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "window.dialogArguments.value = document.getElementById('Text2').value;window.close()", true);
        }