Master pages - organising layout - contentplaceholder confusion

K

kdfake

Ok

Im a bit confused with contentplace holders?!!

Should i use div all the time within them?
 
C

clintonG

Quick answer is yes, we use divs all the time withing the MasterPage as well
as the content pagesThe content template is actually only used at design
time and is not actually compiled as such -- only its contents -- which is
why they are called "place holders."

You can start getting deeper insight by keeping trace enabled in a page
while designing and building. Read the control tree and look for your
controls. You'll observe controls prefixed with ctl0 and so on which again
are place holding identifiers to allow the compiler to manage the control
tree hierarchy.

You are going to have to really understand this when you start trying to
reference controls and their properties. At first it can be very confusing
when a control is a child of a child of a child of a parent control which
can be very common when working with templated controls.
Templating becomes a neccessity when one realizes the canned login controls
and other canned controls in 2.0 are often insufficient for real world
applications and have to be taken apart and rebuilt using templates which
contain our own HTML and CSS.


<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
C

Cowboy \(Gregory A. Beamer\)

The div is a great container control, but you are not limited to a <DIV> to
organize content within a placeholder. It is really your decision. The div
makes it easy to add styles to a complete section, however, so it is a nice
way to encapsulate a particular area.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
C

Cowboy \(Gregory A. Beamer\)

The master page has content holders <asp:ContentHolder>. The page itself has
<asp:Content>. What you decide to put in the content tags is your own
decision. I have seen people put tables directly or even use Panels, which
render as <SPAN> tags. This example, amitedly older, uses a table:
http://msdn2.microsoft.com/en-us/library/zhhddkxy.aspx

Admitedly an older article, but it should still work.

The DIV, to me, is the most useful if you are using CSS, which you should be
as it allows you to change things without major editing. If you want to
organize with tables, instead, it is an option, but it locks up your display
and forces a complete redesign to change things. If you want to see the
value of DIVs with CSS, check out:
http://www.csszengarden.com/

Look at the HTML and CSS file separately and you will see the entire layout
is done with CSS. The downside is you may end up with a mixed bag, as your
master page is probably built with tables and your content with CSS, which
can be confusing. :)

I generally design my sites with PhotoShop (or another graphics program -
Expression Graphic Designer, in beta, is free for now; Paint.NET is also
free, but has fewer options and is difficult for me as a design tool.) I
then lay out a complete page, including common elements, using CSS (static
version). I then apply the common elements to a master page (DWT in non
ASP.NET 2.0 sites) and the rest to content areas. It works rather nicely.

You have to decide how much time you wish to invest in learning these
skills.

Short story: Put what you want in the content tag, but the DIV is a good
container object, esp. if you use CSS.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
C

clintonG

I'd say the "short story" explains what -- not to -- put into a
ContentPlaeHolder and that would be anything except the head, body or form
elements. Just think of content pages as if they were #included as the same
principles apply.


<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 

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,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top