Click here to Skip to main content
15,896,415 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi friends...

i have a label. i want to find that label font size. here i am using

int i=labelid.font.size;

but it not showing any error and also not showing the font size. please help me frnds.

Thanks and Regards
Krishna
Posted
Comments
So, what is value of i ?

I have set the size of my label(under properties->Font->size) as 'large' and the code below gives the size as expected

Size under Font in ASP.net will have values from 'XX-small' to 'XX-Large'

C#
string fontSize =Label1.Font.Size.ToString();
 
Share this answer
 
Create a Label on .aspx page

ASP.NET
<form id="form1" runat="server">
        <asp:label id="Label1" runat="server" text="First Name" font-size="XX-Large" xmlns:asp="#unknown"></asp:label>    
    </form>


on .cs page

C#
protected void Page_Load(object sender, EventArgs e)
        {
           FontSize fontSize = Label1.Font.Size.Type;
           string size = fontSize.ToString();
            Response.Write(size);
        }
 
Share this answer
 
HI

i have posted this already , post comments if you face any issues.

How to get font current size[^]
 
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