jquery學習筆記-jquery結合showModalDialog實現子頁面局部重新整理父頁面

來源:互聯網
上載者:User

欲實現的功能是:在a.aspx頁面有一個下拉框 選擇 然後發現沒有 所要選項。因此需要添加一個 ,此時點擊新增 開啟子頁面b.aspx,在b.aspx頁面實現添加操作後關閉b.aspx頁面,重新整理a.aspx頁面的 下拉框。

 

實現的方式是:jquery結合showModalDialog。以showModalDialog方式開啟b.aspx頁面。在b.aspx頁面操作完成之後返回給a.aspx一個值來,判斷此值決定是否重新整理頁面。

 

a.aspx 關鍵代碼如下:

 

  1. <script type="text/javascript">
  2.     function   openWin()   
  3.     {   
  4.        var   width=320;   
  5.        var   height=100;   
  6.        var   url='addcustorm.aspx';   
  7.        var   returnVal;   
  8.        returnVal=window.showModalDialog(url ,'','dialogWidth='+width+'px;dialogHeight='+ height+'px;resizable=no;help=no;center=yes;status=no;scroll=no;edge=sunken');   
  9.       if   (returnVal=="True")  //當直接點模態表單的X關閉的時候不重新整理首頁面 
  10.       {   
  11.           $(document).ready(function(){
  12.             $("#sc").load("GetCustorm.aspx"); 
  13.             });
  14.       }
  15.    } 
  16. </script>

b.aspx頁面關鍵代碼:

 

b.aspx.cs的事件處理常式添加成功之後

 

  Response.Write("<script>");
                Response.Write("window.returnValue='True';window.close();");
                Response.Write("</script>");

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.