Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASP.NET Label Properties Programmatically

ASP.NET Label Properties Programmatically

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cybersurferdev
    wrote on last edited by
    #1

    Hi I need to set the properties of a label programmatically. Those properties being the font weight and color. Is it possible to do so? Thanks

    D M 2 Replies Last reply
    0
    • C cybersurferdev

      Hi I need to set the properties of a label programmatically. Those properties being the font weight and color. Is it possible to do so? Thanks

      D Offline
      D Offline
      dabs
      wrote on last edited by
      #2

      Yes, Font color is accessible through the ForeColor property. Can't remember the font weight property, but worst case scenario would be to set the CssClass property to a css class which defines font weight according to what you want.


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      1 Reply Last reply
      0
      • C cybersurferdev

        Hi I need to set the properties of a label programmatically. Those properties being the font weight and color. Is it possible to do so? Thanks

        M Offline
        M Offline
        Mike Ellison
        wrote on last edited by
        #3

        This would set the label's font weight to bold and color to green:

        <asp:Label id="lbl1" runat="server"
        Font-Bold="true"
        ForeColor="green" />

        If you needed more control over the font weight, you could use CSS and assign a style class to the label:

        <asp:Label id="lbl1" runat="server"
        CssClass="myLabelClass" />

        To set color & weight programmatically:

        void Page_Load()
        {
        lbl1.Font.Bold = true;
        lbl1.ForeColor = System.Drawing.Color.Green;
        }

        C 1 Reply Last reply
        0
        • M Mike Ellison

          This would set the label's font weight to bold and color to green:

          <asp:Label id="lbl1" runat="server"
          Font-Bold="true"
          ForeColor="green" />

          If you needed more control over the font weight, you could use CSS and assign a style class to the label:

          <asp:Label id="lbl1" runat="server"
          CssClass="myLabelClass" />

          To set color & weight programmatically:

          void Page_Load()
          {
          lbl1.Font.Bold = true;
          lbl1.ForeColor = System.Drawing.Color.Green;
          }

          C Offline
          C Offline
          cybersurferdev
          wrote on last edited by
          #4

          Thanks For all the help Guys. Can this be done with a linkbutton too? -- modified at 3:13 Wednesday 19th April, 2006

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups