asp.net中的模态对话框

asp.net中的模态对话框   


1、显示对话框:  
    在jscript脚本文件中加入:    
        function   OpenEditWin(frmWin,width,height)    
    {                
      var   me;    
      //   把父页面窗口对象当作参数传递到对话框中,以便对话框操纵父页自动刷新。    
      me   =   window;    
      //   显示对话框。    
      window.showModalDialog(frmWin,me, 'dialogWidth= '+width   + 'px;dialogHeight= '+height+ 'px;help:no;status:no ')    
    }    
      在C#中调用   :  
cmdAdd.Attributes.Add( "onclick ", "javascript:OpenEditWin( ' "   +   Session[ "showForm "]   +   " ',540,400) ");    
  很多方法是用   Response.Write或者RegisterStartupScript   来实现,但是都存在问题,如显示对话框时页面是空白、刷新页面的时候弹出对话框等。  
在对话框中加入:   function   onsubmit()   //   强制本窗口提交    
    {    
      document.Form1.target= "_self ";    
    }    
  2、关闭对话框    
        Response.Write( " <script   language= 'javascript '> ");    
      Response.Write( "window.close() ");    
      Response.Write( " </script> ");    
  3、对话框关闭后,执行更新操作  
      在对话框的关闭事件中加入:    
    Response.Write( " <script   language= 'javascript '> ");    
      Response.Write( "window.close() ");    
      Response.Write( " </script> ");    
  4、更新主页面中的表格数据。  
    在“添加”按钮的处理方法中,添加表格更新的代码。      
posted @ 2008-11-07 20:11  草莓爸  阅读(299)  评论(0编辑  收藏  举报