Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 414359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:16:30+00:00 2026-05-12T18:16:30+00:00

My goal is to be able to define a class for the element in

  • 0

My goal is to be able to define a class for the element in a child page. On my master page I have the following:

<body class="<myown:AttributePlaceHolder runat="server" ID="BodyCssClass"/>">

The AttributePlaceHolder derives from ContentPlaceHolder, and just strips out any linebreaks and extra spaces from its content. The problem I will describe also occurs when changing the AttributePlaceHolder into a normal ContentPlaceHolder .

Now the above stated piece of code doesn’t work, and will end up in the following error:

Cannot find ContentPlaceHolder
‘BodyCssClass’ in the master page
‘/Views/Shared/Site.Master’, verify
content control’s ContentPlaceHolderID
attribute in the content page

When changing the above line of code into:

<body class="<% %><myown:AttributePlaceHolder runat="server" ID="BodyCssClass"/>">

It does work (note the added <% %>).

It does the trick, just wondering if I’m missing something here.

Just for the extra info, in my child pages I can write:

<asp:Content ContentPlaceHolderID="BodyCssClass" runat="server">profile-edit someotherclass another-class</asp:Content>

or even:

    <asp:Content ContentPlaceHolderID="BodyCssClass" runat="server">profile-edit
someotherclass

another-class
</asp:Content>

and it will be nicely printed out as:

<body class="profile-edit someotherclass another-class">

Edit
As pointed out by Johan the following also works:

<body class='<myown:AttributePlaceHolder runat="server" ID="BodyCssClass"/>'>

Changes the double quotation marks into single ones.

But than my html would also show up with single quotation marks. Call me crazy, but that just hurts me…

I guess it has to do with the ASP.NET parsing engine, in that case should we call it a bug, or a “feature”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:16:30+00:00Added an answer on May 12, 2026 at 6:16 pm

    You can also achieve the double quotation marks in the output without using the server tags by reversing the quotes setup:

    <body class="<myown:AttributePlaceHolder runat='server' ID='BodyCssClass'/>">

    The runat and ID attributes of the place holder are single quoted. As to why the server tag makes the original code work, only the demons inside the parsing engine know that…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Goal I would like to have a main processing thread (non GUI), and
My goal is to maintain a web file server separately from my main ASP.NET
The goal: To create a .NET dll i can reference from inside SQL Server
I have a page that has 2 columns of words, 20 total, that are
I'm using this in conjunction with the tablesorter plug-in, my goal is to have
I have a view defined in SQL server 2008 that joins 4 tables together.
My goal is to be able to write this in XAML: <Grid> <Rectangle Fill=AliceBlue
Goal Java client for Yahoo's HotJobs Resumé Search REST API . Background I'm used
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do
My goal here is to create a very simple template language. At the moment,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.