我想做一个Web页面(父窗口),其中包含有一个上传文件的链接,我想在单击该链接后打开一个新窗口(子窗口),来实现文件的上传,文件上传完毕后,将文件的上传路径写入父窗口的一个Label中,请都如何实现。哪有这种窗体互动的详细资料啊?

解决方案 »

  1.   

    在html 中写类似window.open 的语句,你到网上查一下,打开新窗体,这样的文章很多的。你把文件上传的代码写在一个页面中,父页面与子页面通过session传值即可,
      

  2.   

    用Session不可能在传完后就把文件的上传路径写入父窗口的一个Label中啊
      

  3.   

    你用window.open 打开这个窗口。 然后
    openner对象就是父窗口了。
    然后使用javascritp改变其中的一个span(就是你说的那个label)就可以。
      

  4.   

    弹出窗口传值回主窗口(2005下测试成功)
    1:Main.aspx:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Main.aspx.cs" Inherits="Temp_Pop_Main" %><!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="form1" runat="server">
        <div>
            <asp:Button OnClientClick="OpenWin()"  ID="Button1" runat="server" Text="Button" />
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
        </form>
    </body></html>
    <script>
    function    OpenWin()
    {
        var ReturnValue=new Array();
         ReturnValue[0]=document.all.TextBox1.value;
        window.showModalDialog("Pop.aspx",ReturnValue,"dialogHide:yes;dialogWidth:300px;dialogHeight:300px");
         document.all.TextBox1.value    =ReturnValue[0];   
    }
    </script>2:Pop.aspx:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Pop.aspx.cs" Inherits="Temp_Pop_Pop" %><!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 onload="SetData()" onunload="GetData()">
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Button OnClientClick="GetData();window.close();" ID="Button1" runat="server" Text="Button" /></div>
        </form>
    </body>
    </html>
    <script>
    var     ResponseValue=window.dialogArguments;
    function    SetData()
    {
        document.all.TextBox1.value=ResponseValue[0];
    }
    function GetData()
    {
    ResponseValue[0]=document.all.TextBox1.value;
    }
    </script>
      

  5.   

    前几天刚好写过一个类似的东东。
    在父窗口中用脚本 window.open 打开新的窗口,这样在新的窗口中可以用 window.opener 对父窗口进行引用,window.opener 相当于父窗口中的 document 。
    另外,提醒一下,在父窗口中,不能用Label控件,客户端脚本无法操作Label控件,应该使用“System.Web.UI.HtmlControls.HtmlInputHidden”控件。这样可以将客户端改变的数字传入到服务器端。
      

  6.   

    全是客户端的操作呀,明白了,搞定,谢谢!
    this.opener.document.getElementById("txtModelPosition").value="OK";
    确实不能用Lable控件,用Label控件,虽然能够修改,但是提交后,值丢失了。改用TextBox就没事儿。(我把Label和TextBox都设置了只读属性)
      

  7.   

    TextBox也可以,不过最好是HtmlInputHidden,节省数据量,提高性能。