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 8723391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:36:55+00:00 2026-06-13T07:36:55+00:00

I’m trying to figure out how to apply CSS to a Label created in

  • 0

I’m trying to figure out how to apply CSS to a Label created in C#. Everything compiles and runs, it just doesn’t seem to be applying the CSS. The CSS is in the file linked to in the site master page. Everything else in the CSS file is being applied as it should be.

Codebehind:

...
Label label = new Label();
SqlCommand command = new SqlCommand("SELECT Q_Text FROM HRA.dbo.Questions WHERE QID = 1");
command.Connection = connection;
reader = command.ExecuteReader();
reader.Read();
label.Text = reader["Q_Text"].ToString();
label.ID = "rblabel";
label.CssClass = "rblabel";
reader.Close();
holder.Controls.Add(label);
...

ASP:

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <asp:PlaceHolder ID="holder"  runat="server">

    </asp:PlaceHolder>
</asp:Content>

CSS:

.rblabel {
    text-align:left;
    padding-left: 2em;
    font-size: 4em;
}

EDIT: added the HTML as well as the Control.Add() statement in my code (forgot to include that in my copy/pase). This HTML is the etirety of what is put into that PlaceHolder.

HTML:

<section class="content-wrapper main-content clear-fix">
    <span id="MainContent_rblabel" class="rblabel">TEST TEST TEST</span>
    <table id="MainContent_ctl00" class="radio">
    <tr>
        <td><input id="MainContent_ctl00_0" type="radio" name="ctl00$MainContent$ctl00"value="1" />
        <label for="MainContent_ctl00_0">Excellent</label></td>
    </tr><tr>
  <td><input id="MainContent_ctl00_1" type="radio" name="ctl00$MainContent$ctl00" value="1" />
         <label for="MainContent_ctl00_1">Good</label></td>
    </tr><tr>
   <td><input id="MainContent_ctl00_2" type="radio" name="ctl00$MainContent$ctl00"value="1" />
          <label for="MainContent_ctl00_2">Fair</label></td>
    </tr><tr>
   <td><input id="MainContent_ctl00_3" type="radio" name="ctl00$MainContent$ctl00"value="1" />
         <label for="MainContent_ctl00_3">Poor</label></td>
    </tr>
</table>
</section>
  • 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-06-13T07:36:56+00:00Added an answer on June 13, 2026 at 7:36 am

    There are basically two possibilities:

    1. Your label may not be rendering with the CLASS attribute set to the desired CSS class. That you can verify by looking at the rendered HTML. (If the label doesn’t appear at all, your code suggests you may not be adding it to the Controls collection of its parent.)

    2. Everything is rendering right, but it’s not appearing correctly in your browser, due to some problem with your CSS or with another stylesheet overriding it. To debug this, you will need to use Firebug or IE’s developer tools.

    Good luck!

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

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.