ASP.NET Label Properties Programmatically
-
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
-
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
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!
-
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
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;
} -
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;
}Thanks For all the help Guys. Can this be done with a linkbutton too? -- modified at 3:13 Wednesday 19th April, 2006