Tutorial :Master page different layouts


Better to explain with the example. :)

Let's say that I have two master pages (or more). The first master page have some plain layout with two content place holders and the second master page have more complex layout with four content place holders.

When I am manually creating a page to use each of the master pages, VS will add the content place holders according to place holders inside the selected master page.

My question is how can I do the same thing programatically?

I have seen skins and templates, but that just change the appearance of the page, not layouts itself.



I hope it meet your need!

in new pages constructor implement this:

this.MasterPageFile = "master page file name";  this.Controls.Add(new Content().ContentPlaceHolderID = "name of ContentPlaceHolder in Selected Master Page!");  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »