form1中textbox1,textbox2的数据分别来自网页对话框form2中的listbox1.selecteditem,dropdownlist3.selecteditem;当点击网页对话框form2上的确定时,将数值传递到form1,并刷新页面。该如何实现,请各位高手指点。

解决方案 »

  1.   

    local accomplish it you can choose js
    run server, just set access of textbox1 and textbox2 to public, then you can use them at other form
      

  2.   

    Response.Redirect("XX_NewTrain.aspx?textbox1=" & str1 & "&textbox2=" & str2)
      

  3.   

    to  lalac(水月流影) 
    可以说详细一些吗?是不是需要在webform2添加对webform1的引用?然后用类的属性进行传递?
      

  4.   

    有了解showModalDialog的吗?我想用这个来实现。但是我不会用。
    在网上看了几篇文章也没看懂。不知哪位高手愿意给解释一下?
      

  5.   

    你要问传递还是showModalDialog?给我发消息吧。
      

  6.   

    第一个页面是WebForm2,第2个才是WebForm1,不好意思弄反了。下面是全部代码,已经编译通过。
    chuandi(传递)是名字空间WebForm2:
    <%@ Page language="c#" Codebehind="WebForm2.aspx.cs" Inherits="chuandi.WebForm2" %>
    <HTML>
    <HEAD>
    <title>WebForm2</title>
    </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
    <asp:Button id="Button1" runat="server" Text="传"></asp:Button>
    </form>
    </body>
    </HTML>
    using System;
    namespace chuandi
    {
    public class WebForm2 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.Button Button1;
    public string Text1
    {
    get
    {
    return this.TextBox1.Text;
    }
    }
    private void Page_Load(object sender, System.EventArgs e)
    {}
    override protected void OnInit(EventArgs e)
    {
    InitializeComponent();
    base.OnInit(e);
    }
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load);
    }
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Server.Transfer("WebForm1.aspx");
    }
    }
    }
    WebForm1:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" Inherits="chuandi.WebForm1" %>
    <%@ Reference Page="WebForm2.aspx" %>
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:Label id="Label1" runat="server">Label</asp:Label>
    <asp:Button id="Button1" runat="server" Text="返回"></asp:Button>
    </form>
    </body>
    </HTML>
    using System;
    namespace chuandi
    {
    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.WebControls.Label Label1;
    public chuandi.WebForm2 wf2;
    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    wf2=(chuandi.WebForm2)Context.Handler;
    Label1.Text="上页传来的是:"+wf2.Text1;
    }
    }
    override protected void OnInit(EventArgs e)
    {
    InitializeComponent();
    base.OnInit(e);
    }
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load);
    }
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Server.Transfer("WebForm2.aspx");
    }
    }
    }
      

  7.   

    showModalDialog Method  
    --------------------------------------------------------------------------------Creates a modal dialog box that displays the specified HTML document.SyntaxvReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
    ParameterssURL Required. String that specifies the URL of the document to load and display. 
    vArguments Optional. Variant that specifies the arguments to use when displaying the document. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values passed by the caller from the dialogArguments property of the window object. 
    sFeatures Optional. String that specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values: dialogHeight:sHeight Sets the height of the dialog window (see Res for default unit of measure). 
    dialogLeft:sXPos Sets the left position of the dialog window relative to the upper-left corner of the desktop. 
    dialogTop:sYPos Sets the top position of the dialog window relative to the upper-left corner of the desktop. 
    dialogWidth:sWidth Sets the width of the dialog window (see Res for default unit of measure). 
    center:{ yes | no | 1 | 0 | on | off } Specifies whether to center the dialog window within the desktop. The default is yes. 
    dialogHide:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default is no. 
    edge:{ sunken | raised } Specifies the edge style of the dialog window. The default is raised. 
    help:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes. 
    resizable:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window has fixed dimensions. The default is no. 
    scroll:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays scrollbars. The default is yes. 
    status:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows. 
    unadorned:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default is no. 
     
      

  8.   

    多谢syeerzy(快乐永远)  我看一下 有问题给你发信息问你
      

  9.   

    想不到NET区连这样的问题分也没人抢了!寒~~~
      

  10.   

    给你模态窗口的用法:关于模态窗口(showModalDialog)的专题讨论!
    1.模态窗口的打开
    2.模态窗口的关闭
    3.模态窗口的传递参数。
    4.其他。
    1.window.showModalDialog("DialogPage.aspx","newwin","dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");2.window.close();3.传值
    ParentPage.aspx:
    window.showModalDialog("DialogPage.aspx?para1=aaa&para2=bbb");DialogPage.aspx:
    string str1=Request.QueryString["para1"].toString();
    string str2=Request.QueryString["para2"].toString();返回值
    DialogPage.aspx:
    window.returnValue="aaa";ParentPage.aspx:
    var str=window.showModalDialog("DialogPage.aspx");4.
    aspx页面在showmodeldialog情况下为什么一提交就重新打开一个页面?
    showmodaldialog打开的页面中在<head></head>之间加入一行:<base target="_self">
      

  11.   

    我得是这么写的,请各位看看哪儿错了
    Open:
    function dialwinprocess()
    {
         var str = window.showModalDialog("SelectName.aspx","window","dialogHeight:450px;dialogWidth:213px;Help:No;Resizable:No;Scroll:auto;Status:no;");

         if(str!=null)
        { 
             document.Default.txtName1.Text=str;
        }
    }ReturnValue and Close:function ReturnValue()
    {
    window.parent.returnValue=document.SelectName.ListBox1.SelectedItem.Text ;
    window.close(); }出错信息是document.SelectName.ListBox1不是对象或为空
      

  12.   

    ps:
    SelectName为网页对话框的id
      

  13.   

    终于 解决了 用window.dialogArguments
    大家有兴趣的可以再讨论,我把这个模块写完再揭帖。