Programmatically Create "Content" Areas for a Master Page

K

Kevin Frey

We have a data-centric application where all of the "layout" for each data
centric page is to be codified (ie. it is expressed in C# code rather than
being expressed declaratively). This codification subsequently produces the
required web-controls for a page based on whether the page is eg. in view or
update mode, examination of the user's security permissions for certain
fields, etc.

In VS2003 our "Page Master" (to use the VS2005 term) was a file that was
#included by each .aspx page and contained a number of "PlaceHolder"
controls where the "content" of the page was attached to. Hence we received
a similar outcome to Master Pages as they exist in VS2005.

I am trying to find a satisfactory way of bringing this concept across to
VS2005 and to use its Master Pages feature rather than our previous
"workaround".

My initial approach was to [try] programmatically generate "Content"
controls and add them to the Page's Control container, and advise each
Content object its ContentPlaceHolderlID to associate to the Master Page.
When I try do this I get an error stating that I cannot programmatically
assign a ContentPlaceHolderID to a Content object.

So this leaves me wondering how the asp parser creates a Content control
and/or where they "end up".

My workaround would to be to use the Master Page, but then I still need a
#include in order to include the content place holders that I will use on
each page. And since I'm still using #include, I don't see any advantage to
this versus my original method.

If anyone can advise some alternative techniques I'd appreciate it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top