Click here to Skip to main content
Click here to Skip to main content

FontInfo property for ASP.NET components

, 5 Dec 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
An article on how to create a FontInfo property for an ASP.NET component.


During the development of some ASP.NET components, I experienced a bit of a trouble implementing the FontInfo property for ASP.NET components. First of all, I didn't find a public constructor for the FontInfo class. But there is a Style class which could be used to create a FontInfo instance.

FontInfo  _myFont;
Style _style;
_style=new System.Web.UI.WebControls.Style();
_myFont =style.Font;

Another thing I've found is that the newly created FontInfo property is not serialized in the ASPX form like other properties. And every time I reopen the web form, at design time, the FontInfo property gets its default value = "". This problem was solved by adding the DesignerSerializationVisibility attribute:

   Description ("My font property.")>
public FontInfo MyFont

Now the control on the web form serializes the information about the FontInfo property:

<cc1:mywebcontrol id="MyWebControl1" runat="server" 
        Height="50px" Width="450px"
        MyFont-Names="Century Gothic" MyFont-Italic="True" >

Hope that helps!


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


About the Author

Tadas Budvytis
Team Leader
Canada Canada
No Biography provided

Comments and Discussions

QuestionSerialization PinmemberSquid.net29-Apr-07 20:40 
GeneralThanks for the time saver. PinmemberSquid.net29-Apr-07 19:41 
GeneralGreat tip Pinmemberabhiace28-Feb-06 13:23 
GeneralRe: Great tip PinmemberPeraxel12-Apr-07 0:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150326.1 | Last Updated 5 Dec 2005
Article Copyright 2005 by Tadas Budvytis
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid