Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Web.UI.WebControls.Label

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
How do I set the font for a System.Web.UI.WebControls.Label?

The "font" property is read-only. That is just terribly frustrating. All I want to do is set the font.
 
Okay, I did a workaround. You cannot give .font a font, but you CAN give .font.name a string like "tahoma". You CAN also give .font.size an integer.

Still, it is aggravating that .font is a read-only property.
 
Still, it is aggravating that .font is a read-only property.
.font is a Public Overridable ReadOnly property and is of type System.Web.UI.WebControls.FontInfo which is a class. That is why you have to drill down to the actual properties you can set.
 
Rather than hard-coding these values in your code, a font should be assigned via a css file so that changes can be made vwithout having to recompile and redeply your application.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top