views:

52

answers:

1

Hello all.

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.

Thanks.

A: 

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!");
Jalal Amini
Unfortunately, no.Your code raises an error (cannot convert string to control) then I wrote a bit different, but this again raises an error that setting ContentPlaceHolderID isn't supported.Thanks anyway.
lopkiju