2016-09-13 32 views
0

我正在研究具有主頁/內容頁面的asp.net C#webforms項目。雖然有些內容頁面會有一個頁面特定鏈接的列表,比如在左側的asp.net面板中,其餘的都不會。我想知道什麼是最好的方式來做到這一點。爲此,具有左側導航鏈接的內容頁面將與母版頁進行通信,以便母版頁將顯示或隱藏左側導航面板,並且內容頁面將填充它。具有左側導航與內容網頁的一部分,本身更容易,因爲我是顯示它如下:如何通過asp.net中的母版頁顯示或隱藏內容頁面的左側內容

When the content page had the left nav: 

<div class="row"> 
    <div class="col-md-3"> 
    --Left nave goes here-- 
    </div> 
    <div class="col-md-9"> 
    --Rest of the contents go here-- 
    </div> 
</div> 

When the content page didn't have the left nav: 

<div class="content"> 
    --All the contents go here-- 
</div> 

任何好的辦法通過母版頁做將不勝感激!

回答

0

一個簡單的方法可能是使用Nested Master Pages。因此,您需要擁有大部分HTML的主母版頁,然後再創建兩個使用該主母版頁的母版頁(例如,LeftNav.master和NoLeftNav.master)。然後,您會爲每個內容頁面選擇您想要的主頁面,左側導航頁面或未導航頁面。

祝你好運!