How to set font size in a Label control

I'm trying to specify a font size in a Label control, but the code I thought would work is giving me an error... "Cannot implicitly convert type 'System.Web.UI.WebControls.FontSize' to 'System.Web.UI.WebControls.FontUnit'".  The code causing the error:

Label lbl = new Label();
lbl.Visible = true;
lbl.Font.Size = FontSize.Small;
lbl.Text = (string)schedule[e.Day.Date.ToShortDateString()];
e.Cell.Controls.Add(lbl);
So the question is how do I need to encode a font size change?

"Here's where the fun begins." -- Han Solo
0
Ted
1/24/2008 4:55:49 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

4 Replies
447 Views

Similar Articles

[PageSpeed] 44

 Try the below instead

lbl.Style.Add("font-size","small");

HC 


Haissam Abdul Malak
MCAD.NET
| Blog |
0
Haissam
1/24/2008 5:11:03 PM

It should be

lbl.Font.Size = FontUnit.Small;

 


Please click Mark as Answer for helpful posts!

"Give a man a fish, and he eats for a day. Give him a fishing pole, he will eat for life."

--I'm still a script kiddie at heart.
0
mjnorman
1/24/2008 5:13:32 PM

That worked.  Thanks!

EDIT: Both solutions work, btw.


"Here's where the fun begins." -- Han Solo
0
Ted
1/24/2008 5:17:02 PM

Hi,

Try this

 

Label lbl = new Label();
lbl.Visible = true;
lbl.Font.Size = FontUnit.Small; //FontSize.Small;
lbl.Text = (string)schedule[e.Day.Date.ToShortDateString()];
e.Cell.Controls.Add(lbl);
 Hope it will give you what you are looking for.
Faraz Shah Khan
MCP, MCAD.Net, MCSD.Net, MCTS-Win/Web, MCPD-Web
Blog
0
farazsk11
1/24/2008 5:33:39 PM
Reply:

Similar Artilces:

How to set font size and font style for a THotkey control?
Now I add a Thotkey control on a form.Yes.It is a very useful control to handle hotkey. But how I can set a bigger font and bold style for it. Regards. Jack Xiao > {quote:title=bing xiao wrote:}{quote} > Now I add a Thotkey control on a form.Yes.It is a very useful control to handle hotkey. > But how I can set a bigger font and bold style for it. The THotkey is simply a wrapper around the Windows HOTKEY control. It gets it's font size and style from the user's display settings, using one of the system values (see ComCtrls.pas, procedure TCustomHotKey.AdjustHeight f...

I want to apply some visual properties (such as ForeColor,Font-Size.....etc.) in a string for web control elements (TextBox,Label...etc) visual properties. How can do that?
I want to apply some visual properties (such as ForeColor,Font-Size.....etc.) in a string for web control elements (TextBox,Label...etc) visual properties. How can do that? For example: TextBox tb = new TextBox(); string s = "ForeColor:Red; BackColor:Silver; Font-Name: Arial; Font-Size: XSmall"; s can has different content.  How can I apply the properties in s string to teh textbox tb?   Thanks cbozlagan:I want to apply some visual properties (such as ForeColor,Font-Size.....etc.) in a string for web control elements (TextBox,Label...etc) visual properties...

Controlling fonts and font sizes in a menu control
Am building a menu programically (fragment below):Dim mnuTopics As New MenuItem("Lessons") For i As Integer = 1 To 10    Dim menuLesson As New MenuItem("Subject" & i, Nothing, Nothing, "~/Main.aspx?page=Subject&ID=" & i)    mnuTopics.ChildItems.Add(menuLesson)Next MainMenu.Items.Add(mnuTopics) Dim menuProfile As New MenuItem("Profile", Nothing, Nothing, "~/Main.aspx?action=profile")MainMenu.Items.Add(menuProfile)am unable to programically change menu font sizes. Don't want to access a theme/skin--just want to programmically change the font size ba...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

How to set tabindex to the controls if the total number of the controls on a web form is not sure?
Hi,I have a web form which has a multiview control along with other web controls. Each view of this multiview control has different number of web controls. So if user selects 1. the first view to load then the form has total 10 controls on it (5 control of the form, and 5 controls of the view selected by user)2. the second view to load then the form has total 8 controls on it (5 control of the form, and 3 controls of the view selected by user)3. the third view to load then the form has total 20 controls on it (5 control of the form, and 15 controls of the view selected by user)As i dont kn...

Set web form size
Hi All, I used vb.net to develop web froms. Please let me know how to set size to the web from, I mean in run time I want the webform to open with a certain size (in the browser). how do I do that and I also want to disable the Maximize button. Please lemme know ...

Controlling size of Web Form
Hmm, really like the new site GUI!   I know that this proves me to be very green, but how do I control the size of the web page ? I don't see how to access the height and width properties.... For that you will need to use client side scripting.Rules at work:1) Boss is always right2) If Boss is wrong; refer rule #1 Like javascript ? or can I do it with C# ? What is the code? As of now, you cannot run c# in the web browser. So, I would use only Javascript. If it's intranet app and the officially supported browser is IE, then vbscript can also be used. Check out this link http://...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

superreview requested: [Bug 288906] Return null for MSAA name when no name explicitly set for HTML form control : [Attachment 179538] If no name explictly set for form control, use SetIsVoid(null)
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 288906: Return null for MSAA name when no name explicitly set for HTML form control https://bugzilla.mozilla.org/show_bug.cgi?id=288906 Attachment 179538: If no name explictly set for form control, use SetIsVoid(null) https://bugzilla.mozilla.org/attachment.cgi?id=179538&action=edit ...

superreview granted: [Bug 288906] Return null for MSAA name when no name explicitly set for HTML form control : [Attachment 179538] If no name explictly set for form control, use SetIsVoid(null)
neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 288906: Return null for MSAA name when no name explicitly set for HTML form control https://bugzilla.mozilla.org/show_bug.cgi?id=288906 Attachment 179538: If no name explictly set for form control, use SetIsVoid(null) https://bugzilla.mozilla.org/attachment.cgi?id=179538&action=edit ...

How to change tree view's (web control) back color, font color and font size using CSS (Cascading Style Shteets)
Hi All, I have created tree view (web control) but i want to change all the properties of it, through single style sheet. Like all other controls (label, text box and combo box) it's not possible to change all the properties of treeview through single style sheet by including it to the contol ???? Please help........ MAITRAY. Sorry. No external css. but these attributes: DefaultStyle="background:#CCCCCC;border:solid 1px;color:black;font-size:8pt" HoverStyle="color:blue;font-name:Arial" SelectedStyle="c...

.Net Windows Control in Web Form
Hi all,How can I use a .Net windows control in a web form? I use object tag but it doesn't work and displays empty.Thanks in advance cheers Hi, you can check this article out: Hosting a Windows Control in a Web Form. This shows only how to host the control. If you want interaction with the client you can do this by setting the correct CAS (Code Access Security) settings on the client pc. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Thanks guys for your replycheers...

What controls the initial size of a Web Form?
Is there a setting in IE that controls the coordinates at which a web form opens and its size? My forms never open full-screen and the location seems to change over time. I looked under the Tools | Internet Options menu but didn't see anything. Thanks for your help. BCB Not as far as I know. I believe it just stores the position and size from the last time it was used and loads those settings."I would love to change the world, but they won't give me the source code." -unknown...

Web resources about - How to set font size in a Label control - asp.net.web-forms

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iHome unveils new SmartPlug model w/ power consumption tracking, remote control support
... the WiFi-enabled SmartPlug adds Siri automation to any two- or three-pronged accessory you have around the house. The accessory is controlled ...

Control Sphero’s awesome BB-8 droid with the upcoming Force Band
... with Spheros enormously fun BB-8 droid . And at CES 2016 in Las Vegas, the company announced that users will soon have another way to control ...

The Volkswagen Golf will get gesture controls
Filed under: 2016 CES , Volkswagen , Technology , Hatchback , Electric Want to see the new tech that's coming to Volkswagen models in the very ...

Now You Can Use Siri to Control Your Shades
... their Caséta Wireless Smart Bridge, a smart home device that could be used with their range of on/off and dimmer switches to give people control ...

Why Gun Control Laws Work Elsewhere But Are DOA In The USA
... lands with diverse populations and long histories of fidelity to the rule of law. Why then did Australia and the U.K. pass strict gun control ...

MLK Packed Heat But Obama Cites Him To Shame Gun Control Opponents
MLK Packed Heat But Obama Cites Him To Shame Gun Control Opponents

AT&T voice assistant helps you control your smart home
AT&amp;T's Digital Life home automation service is supposed to make your life easier, but it's been lagging a bit in the control department. ...

President Barack Obama Breaks Down in Tears While Announcing Plan for Gun Control
President Obama can't hold back the tears while recalling the Sandy Hook Elementary school shooting.

Indianapolis mom invited to White House for gun control announcement
WASHINGTON, D.C. (Jan. 5, 2016) - DeAndra Yates never intended to become an advocate for gun safety and gun violence victims. But the last two ...

Resources last updated: 1/6/2016 7:39:03 AM