Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to take the font size/font family for a particular label for checking a condition,how to take that
Posted

All you need to do is to access Font properties server side like below:

C#
FontUnit size = Label1.Font.Size;
String[] fontNames = Label1.Font.Names;
 
Share this answer
 
using javascript/jquery, you can proceed like below
Way to set font-size/family
JavaScript
$("#lblID").css("font-size", "150px");
$("#lblID").css("font-family", "arial");

Way to get font-size/family
JavaScript
$("#lblID").css("font-size");
$("#lblID").css("font-family");
 
Share this answer
 
Comments
[no name] 19-Sep-14 2:33am    
Your answer is correct, my 5+ , but why do we need to write two lines. See my answer mate!
Before jQuery 1.9 release it was not possible but one of the new feature of jQuery 1.9 was .css() multi-property getter.

JavaScript
var propCollection = $("#dvBox").css([ "width", "height", "backgroundColor" ]);

In this case, the propCollection will be an array and it will look something like this.

CSS
{
  width: "100px",
  height: "200px",
  backgroundColor: "#FF00FF"
}



It will you :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900