Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2012, 06:19 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default The Content Placeholder question

I don't know, maybe I am choking on gnats here but what is the difference between a Content Placeholder and a form element on a web page? Are they pretty much the same thing or not? I don't know why but this really confuses me and I seem to get hung up about this issue. I can't wrap my head around the difference between the two. What is the difference from this:
Code:
<form action="" method="post" enctype="multipart/form-data" name="Contact" id="Contact">

and this:

<asp:ContentPlaceHolder id="ContentPlaceholder1" runat="server">
    </asp:ContentPlaceHolder> ?????
Does not the server treat them and display them same when you see the HTML?
Can Content Placeholders be manipulated and defined through CSS just like any other HTML element?

Thanks once again!
 
Old March 2nd, 2012, 06:34 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Second CP question

Is it absolutely necessary that the content placeholder that is in the body of the HTML page run under a form element, or can it be independent and run outside of a form element? Can you, have action functionality like get and post with Content Placeholders like you do with forms?

Thanks once again.
 
Old March 2nd, 2012, 06:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

There's a huge difference. The form element is needed in each page (in the master page or in a normal ASPX page that is not based on a master page) to enable most of ASP.NET's functionality.

A ContentPlaceHolder is a placeholder for content linked to a specific area of the master page. It only lives at the server and has no visual representation in the HTML (and thus cannot be styled).

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 2nd, 2012, 07:05 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default So I can't do this:???

Code:
Assuming this in your .NET code in your masterpage:

<asp:ContentPlaceHolder id="XP1" runat="server">

   </asp:ContentPlaceHolder>


I can't do this in my CSS file for any HTML element that is contained within the Content Placeholder like a <p> element, and do something like this in my CSS?:

#XP1 .<p> Strong{
Color: #207EBF;
margin-left : 15px;
}
That would not work?
I know for a fact that you can do this in the HTML: 
With a div:
 <div id="Main">
<p> Put something here </p>
</div>

then manipulate in the CSS code like this:
#Main .p Strong{
Color: #207EBF;
margin-left : 15px;
}
Can you not?
Thanks again.
 
Old March 2nd, 2012, 07:18 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default I guess what I am really asking here is....

If I want all or some of my HTML elements that are in the master page inside the content placeholder to look the same or uniform across all webpages, what is the best approach that you recommend that we should take? Could we not use the ID of the Content placeholder in the master page and then manipulate the HTML elements in the CSS? Could we not do that?
 
Old March 2nd, 2012, 07:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take another look at this:

Quote:
A ContentPlaceHolder is a placeholder for content linked to a specific area of the master page. It only lives at the server and has no visual representation in the HTML (and thus cannot be styled).
A ContentPlaceHolder does *not* end up in the browser and as such cannot be targeted by CSS.

Of course there is nothing stopping you from adding an element *to* or *around* the ContentPlaceHolder and use that in your CSS.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
placeholder in query sir_com ASP.NET 2.0 Basics 2 August 13th, 2010 06:35 AM
Setting content placeholder width mistat2000 ASP.NET 2.0 Basics 1 January 21st, 2009 08:22 AM
Placeholder grstad ASP.NET 2.0 Basics 6 May 23rd, 2008 09:03 AM
Navigate away from a Content Placeholder slbibs SharePoint Development 0 September 4th, 2007 03:28 PM
placeholder controls rocksbhavesh ASP.NET 1.0 and 1.1 Professional 3 May 17th, 2007 08:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.