从A.aspx弹出一新IE窗口B.aspx,在B.aspx里选取数据stringB后关闭B.aspx,请问怎么把这个stringB动态添加到A.aspx的指定文本框里,即只要在B.aspx的dropdownbox(或其他控件)里选取时,A.aspx的特定文本框就显示出这个数据,当然,中间可以在B.aspx加个确定按钮,当确定后A.aspx的文本框再显示出这个stringB也是可以的
在B.aspx触发使A.aspx重新Page_Load使得stringB能够显示,这种方法应该可取,但我不知道能不能实现,到底怎么实现
谢谢各位

解决方案 »

  1.   

    a.htm
    js
    var win=window.open("b.htm")b.htmjsself.opener.document.getElementById("a.htm.textbox.id").value=self.document.getElementById("self.textbox.id").value
    self.close()
      

  2.   

    弹出窗口用 showModalDialog ,可以接受返回值。参考:http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties.aspThe Perfect Modal 部分
      

  3.   

    window.opener.from(A.aspx 中的form).控件.属性=XXX
      

  4.   

    用脚本
    <script language="javascript">
    function GetQueryWhere(str)
    {
    var Pwin = window.opener ;
    Pwin.document.all["TextBox1"].value = str;
    window.close();
    }
    </script>
      

  5.   

    window.opener.from(A.aspx 中的form).控件.属性=XXX
      

  6.   

    WebForm2.aspx:
    <%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="sell.module.WebForm2" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm2</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <base target="_self">
    <script language="javascript">
    function foreColor1(maincol)
    {
    var arr;
    arr= showModalDialog('WebForm3.aspx','', 'dialogWidth:265px; dialogHeight:80px; status:0'); if(arr!=null)
    {
    document.all('b1').value=arr;
    }
    }
    </script>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="WebForm2" method="post" runat="server">
    <FONT face="宋体">
    <TABLE id="Table1" style="Z-INDEX: 103; LEFT: 208px; WIDTH: 273px; POSITION: absolute; TOP: 150px; HEIGHT: 52px" cellSpacing="0" cellPadding="0" width="273" border="0">
    <TR>
    <TD>
    <INPUT style="WIDTH: 205px; HEIGHT: 44px" type="text" size="28" id="b1"> <INPUT id="Button1" style="WIDTH: 58px; HEIGHT: 44px" type="button" value="B1111" name="Button1" onclick="javascript:foreColor1(b1)"></TD>
    </TR>
    </TABLE>
    </FONT>
    </form>
    </body>
    </HTML>
      

  7.   

    WebForm2.cs为默认!
    WebForm3.cs:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace sell.module
    {
    /// <summary>
    /// WebForm3 的摘要说明。
    /// </summary>
    public class WebForm3 : System.Web.UI.Page
    {
    protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
    protected System.Web.UI.WebControls.TextBox TextBox1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.ServerClick += new System.EventHandler(this.Button1_ServerClick);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    private void Button1_ServerClick(object sender, System.EventArgs e)
    {
    string str=this.TextBox1.Text.ToString().Trim();
    this.Page.RegisterStartupScript("0","<script>window.returnValue='"+str+"';window.close();</script>");
    }
    }
    }
      

  8.   

    WebForm3.aspx:
    <%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="sell.module.WebForm3" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm3</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <base target="_self">
    <script language="javascript">
    function ccc()
    {
    window.opener=null;
    window.close();
    }
    </script>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="WebForm3" method="post" runat="server">
    <FONT face="宋体">
    <TABLE id="Table1" style="Z-INDEX: 103; LEFT: 6px; WIDTH: 265px; POSITION: absolute; TOP: 163px; HEIGHT: 44px" cellSpacing="0" cellPadding="0" width="265" border="0">
    <TR>
    <TD>
    <asp:TextBox id="TextBox1" runat="server" Height="34px" Width="203px"></asp:TextBox>
    <INPUT id="Button1" style="WIDTH: 58px; HEIGHT: 36px" type="button" value="B2222" name="Button1" runat="server" ></TD>
    </TR>
    </TABLE>
    </FONT>
    </form>
    </body>
    </HTML>
    =============================================================
    可运行的成功的 我刚为你做的弹出窗口( showModalDialog)
    用属性返回值
      

  9.   

    各位大哥大姐真是太好了,谢谢ing
      

  10.   

    to softchao(【∵笑了∵】:
    我想从webform2向webform3传送数据,该怎么办?因为有很多form要共用这个webform3,所以我要根据传入webform3值的不同决定webform3的显示样式
    谢谢