Can I use the same content page with two different main pages?

I have an asp.net content page that is used inside the main page (with a title, menu, and some links). I would like to use it in a different context without a main page (so as not to display the title and menu there) or with an empty main page, if possible. I do not want to violate the DRY principle by taking the entire page and creating a separate clone of this for obvious reasons. Is it possible?

+4
source share
2 answers

Yes, you can set the home page dynamically on Page_PreInit content pages:

private void Page_PreInit(object sender, EventArgs e) { this.MasterPageFile = "MyMasterPage.master" } 

Set some logic to dynamically choose which file name of the main page to go through, and now you share one page of content with many main pages.

+4
source

Source: https://habr.com/ru/post/1301322/


All Articles