紀錄一下,
我原本有一支 Web 程式,畫面像圖中上面那樣,
有幾個欄位、一個 Grid 、當 Grid 點選不同紀錄時,
下面的 Tab 內容就會依選中的資料,重新繫結資料內容。
這支程式暫且叫他 HostPage ,
他會 Implement 一個 IHost 的 Interface ,
Usercontrol 若要存取 HostPage 中的資料,一律透過 IHost 進行。
而每個 Tab 中的內容則是鑲入 Usercontrol ,
該 Usercontrol 會 Implement 一個叫 Itabcontent 的 Interface ,
HostPage 要操作 Usercontrol 時,也一律透過 Itabcontent 進行。
在開發的過程中 Tab 內容越來肥,導致整個頁面載入都明顯的變慢許多,
於是我們想把 Usercontrol 鑲到一個無縫的 iframe 中,讓他看起來像下圖下面那樣,
因為一開始的設計就透過 Interface 將 HostPage 與 Usercontrol 分開,
所以變成下面鑲入 iframe 的過程,沒有多大的困難,
原本的 Usercontrol 改成一支 Usercontrol_Relay , Relay 網頁中放一個 iFrame ,
Relay 則是當需要的時候把相關資訊 post 給 iframe 中的 AnotherHostpage ,
而 AnotherHostpage 則是把從 Relay 接收到的參數轉換成 IHost 定義的屬性,
並依參數決定要鑲入的 Usercontrol 是哪一個,讓原本的 Usercontrol 改放在 AnotherHostpage 中。
當然,Usercontrol_Relay 要 Implement Itabcontent
AnotherHostpage 也要 Implement IHost。
沒有留言 :
張貼留言