Info.apsx显示信息页面,在此页面中通过dataList显示商品的信息,在修改按钮的单击事件中保存商品的id并通过showModalDialog弹出一个网页。单击事件代码如下:
 Session["ideaId"]=videoId;
        RegisterStartupScript("true", "<script > showModalDialog('frame.aspx','','width=340,height=200','alwaysRaised= yes');</script>");在fram.aspx页面中显示amend.aspx页面。在此页面中可以防止提交后弹出新页面问题。代码如下:
<frameset rows="0,*">
<frame src="about:blank" />
<frame src="amend.aspx"/>
</frameset>
在amend.aspx页面中通过id显示显示商品信息,并可以修改商品信息,单击修改按钮将商品修改后的信息保存到数据库中,保存成功将关闭该页面并返回到info.aspx页面中。代码如下:
 RegisterStartupScript("true", "<script>alert('回复成功!');window.opener.location.href=window.opener.location='info.aspx';window.close();</script>");
但出现‘window.opener.location’为空或不是对象的错误。请教大家该如何解决此问题。

解决方案 »

  1.   

    window.dialogArguments.document.location.reload();注意中间这个传window对象
    window.showModalDialog(sUrl,window,sFeatures);
      

  2.   

        演示ASP.NET 窗体传值     
    =================     =================
    function vv()
        {
            kv=window.showModalDialog("test2.aspx",window);
            
             /* 1
             var newoption=document.createElement("Option")
          newoption.text=kv;
          document.getElementById("ee").options.add(newoption);     
          */
          
          /*2*/
          var option=new Option(kv,kv);             
                   document.getElementById("ee").options.add(option);
        } function cc()
       {
       /*一种方案:子窗体直接给父窗体赋值,事件全部在子窗体中处理*/
           window.dialogArguments.document.Form1.Text1.value=document.getElementById('s2').value;      
          /* 正确赋值*/
              var newoption=window.dialogArguments.document.createElement("Option")
        newoption.text=document.getElementById('s2').value;
        window.dialogArguments.document.getElementById("ss").options.add(newoption); 
        
        /*第二种方案:子窗体将值传回父窗体,由父窗体处理*/
        window.returnValue= document.getElementById('s2').value;
           
           window.close();
       }
      

  3.   


    防止提交弹出新页面 ,只需要在 那个页面 html 与 body 之间加上
    <base target=_self>
      

  4.   


    使用:<base target="_self">提交表单后,页面内容错位。
      

  5.   

    感谢一楼,但现在新的问题又出现了。当我使用下面的代码返回主窗体时,出现一个对话框“不重新发送信息,则无法刷新”。这个问题怎么解决呀?????
    RegisterStartupScript("true", " <script>alert('回复成功!');window.dialogArguments.document.location.reload();;window.close(); </script>");
      

  6.   

    try
    window.dialogArguments.document.location.href = window.dialogArguments.document.location.href;
      

  7.   

    感谢大家!该问题已经解决:
    首先使用window.showModalDialog(sUrl,window,sFeatures);打开一个网页对话框。在该网页对话框中进行修改或其他操作后,使用如下代码返回主窗体并刷新主窗体:
    RegisterStartupScript("true", "  <script>alert('回复成功!');window.dialogArguments.document.location.href = window.dialogArguments.document.location=‘sUrl’;window.close();  </script>");