By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

Programmatically Create "Content" Areas for a Master Page

P: n/a
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.
Sep 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.