views:

153

answers:

3

I've got a Master Page with multiple ContentPlaceHolders. One of them will sometimes be empty. If they both have content, I'd like to make visible a buffer so there is some space between them, but this should remain hidden otherwise.

My question is, how can I determine from the C# code-behind of my Master Page whether the ContentPlaceHolder of a child page has any content assigned to it? All I really want is a boolean yes/no answer.

Thanks!

A: 

perhaps

YourContentPlaceHolder.Controls.Count > 0

Would that work for you?

Robban
I don't think this will work if plain HTML is placed there. As far as I know only the server side controls are in the .Controls property.
Gertjan
A: 

Maybe I am missing something, but it seems you just need to get spacing. Why not just wrap the first ContentPlaceHolder in a div with a padding-bottom? There may be a more efficient way to do this, but you get the idea.

Nate Pinchot
A: 

You could programmatically add a div to your first ContentPlaceHolder with something like ...

<div class="spacer" />

and in your css have this ...

div.spacer { margin-bottom: 5ex; }

you may need to put a &nbsp in the div to get around some browser bugs :)

Antony Scott