在模式窗口与主窗口之间传值,怎样实现?
我试了一下,Session也不行

解决方案 »

  1.   

    客户端:showModalDialog(url,windowname,Argument,...)
    有一个Argument参数可以用来往对话框传数据,对话框返回的话可以用returnValue来传
    数组,docment对象都可以传。具体的网上找下服务器端:有URL后面加参数,session都可以的
      

  2.   

    在主页面上,
    Session["aa"]=TextBox1.Text;
    Response.Write("showModalDialog(bb.aspx)");
    在模式页面上,
    TextBox1.Text=Session["aa"];取不到主页面上的值,说不对将对象引用到实例.
      

  3.   

    TextBox1.Text=Convert.ToString(Session["aa"]);
    另外,不建议用session,因为可以直接传值的,你可以参考showModalDialog的详细应用。
    也可以用URL传值,例如把URL改成:userInfo.aspx?userId=....
    再在目标页面用Request.QueryString["userId"]来获取。
      

  4.   

    主窗口到模式窗口用URL吧 var st=window.showModalDialog(..?id=...);textbox1.value=st;
    模式窗口到主窗口:window.returnValue=...
      

  5.   

    wht6411(华中科大,即将大四,寻求武汉工作机会)
    在普通页面传值
    "例如把URL改成:userInfo.aspx?userId=....
    再在目标页面用Request.QueryString["userId"]来获取。"
    这种方式是可以,
    但我是用模式窗口的,
    这种方式就不能用了吧,
      

  6.   


    主窗口:
        <script language="javascript">
           function opendialog(){
               var str = window.showModalDialog('default2.aspx');   //打开模态对话框,变量a接收返回值
               document.getElementById("TextBox1").value = str;     //将返回值绑定到TextBox1控件
           }
        </script>按钮:<input type="button" value="打开子窗口" onclick="opendialog()" />子窗口:
    在<head>中加入
    <base target="_self" />按钮事件:
            string struct="要返回的值";
            Response.Write("<script language='javascript'> window.returnValue = '" + struct + "' ;</script>");
            Response.Write("<script language='javascript'>window.close();</script>");