我前天遇到一個 ASP.NET 開發的問題,我有一個網站,其中有些頁面套用了一層的 MasterPage、有些套用了兩層 MasterPage、有些套用了三層 MasterPage,這些套兩層以上 MasterPage 的 MasterPage 在第二層的地方都是套用第一層的 MasterPage,不過客戶突然說第一層的 MasterPage 必須要依據不同的網域名稱(Domain Name)而選用不同的 MasterPage,最後耗了我三個小時才解決這個問題。
MasterPage 的套用關係大致的示意如下:
MasterPageTop.master
-> MasterPageChannel1.master
-> MasterPageChannel1_1.master
-> ContentPage.aspx
而我的需求是要動態變更 MasterPageChannel1.master 裡的 MasterPageFile 屬性,讓 ContentPage.aspx 在顯示的時候將 MasterPageTop.master 改成 MasterPageTop2.master。
... 繼續閱讀 ...