[英]How can I register an assembly in a asp.net master page that is accessible to the content pages?
[英]Can I use the same content page with two different master pages?
我有一個asp.net內容頁面,在主頁面內使用(帶有標題,菜單和一些鏈接)。 我想在沒有母版頁的情況下在不同的上下文中重復使用它(不在那里顯示標題和菜單),或者如果可能的話,可以使用空母版頁。 由於顯而易見的原因,我不想通過整個頁面並創建它的獨立克隆來違反DRY原則。 這有點可能嗎?
是的,您可以在內容頁面Page_PreInit方法中動態設置母版頁:
private void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "MyMasterPage.master"
}
設置一些邏輯以動態選擇要傳入的主頁文件名,現在您正在共享一個包含許多母版頁的內容頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.