Using the Font property

Discussion in 'ASP .Net Building Controls' started by Guest, Feb 10, 2006.

  1. Guest

    Guest Guest

    In a custom control, inherited from WebControl, I get a Font property
    automatically. What's it's purpose. When I render text within the control,
    it's not rendered with the attributes of that font object. Do I have to
    read the attributes of the font object and render each one within a font tag
    manually?

    I'm overriding the RenderBeginTag, RenderContentes and RenderEndTag methods.
    They render a hierarchy of tables and divs, but I want the innertext of the
    innermost element to be rendered in the font selected in the properties
    dialog.

    What am I missing?

    Thanks.

    Jerry
    Guest, Feb 10, 2006
    #1
    1. Advertising

  2. Normally it is applied, but there is a chance you're overriding that default
    functionality. Have you remembered to call the base class functions from
    within your overrides?
    If necessary you can apply the font to your innermost object manually with a
    line something like this:
    SomeControl.Font.CopyFrom(this.Font);


    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    <> wrote in message
    news:...
    > In a custom control, inherited from WebControl, I get a Font property
    > automatically. What's it's purpose. When I render text within the
    > control,
    > it's not rendered with the attributes of that font object. Do I have to
    > read the attributes of the font object and render each one within a font
    > tag
    > manually?
    >
    > I'm overriding the RenderBeginTag, RenderContentes and RenderEndTag
    > methods.
    > They render a hierarchy of tables and divs, but I want the innertext of
    > the
    > innermost element to be rendered in the font selected in the properties
    > dialog.
    >
    > What am I missing?
    >
    > Thanks.
    >
    > Jerry
    >
    >
    Steve C. Orr [MVP, MCSD], Feb 10, 2006
    #2
    1. Advertising

  3. Guest

    Guest Guest

    I'll check the base class calls and see if I can get it going... But the
    rendering is all pretty much manual, so I don't think I have an object to
    copy the font to...

    It's just a div being rendered manually.


    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:...
    > Normally it is applied, but there is a chance you're overriding that

    default
    > functionality. Have you remembered to call the base class functions from
    > within your overrides?
    > If necessary you can apply the font to your innermost object manually with

    a
    > line something like this:
    > SomeControl.Font.CopyFrom(this.Font);
    >
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    >
    > <> wrote in message
    > news:...
    > > In a custom control, inherited from WebControl, I get a Font property
    > > automatically. What's it's purpose. When I render text within the
    > > control,
    > > it's not rendered with the attributes of that font object. Do I have to
    > > read the attributes of the font object and render each one within a font
    > > tag
    > > manually?
    > >
    > > I'm overriding the RenderBeginTag, RenderContentes and RenderEndTag
    > > methods.
    > > They render a hierarchy of tables and divs, but I want the innertext of
    > > the
    > > innermost element to be rendered in the font selected in the properties
    > > dialog.
    > >
    > > What am I missing?
    > >
    > > Thanks.
    > >
    > > Jerry
    > >
    > >

    >
    >
    Guest, Feb 10, 2006
    #3
  4. It would be a bit of a pain to have to render each of the font attributes
    individually, but then again it's probably only a dozen lines of code, so it
    certainly is an option.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    <> wrote in message
    news:%...
    > I'll check the base class calls and see if I can get it going... But the
    > rendering is all pretty much manual, so I don't think I have an object to
    > copy the font to...
    >
    > It's just a div being rendered manually.
    >
    >
    > "Steve C. Orr [MVP, MCSD]" <> wrote in message
    > news:...
    >> Normally it is applied, but there is a chance you're overriding that

    > default
    >> functionality. Have you remembered to call the base class functions from
    >> within your overrides?
    >> If necessary you can apply the font to your innermost object manually
    >> with

    > a
    >> line something like this:
    >> SomeControl.Font.CopyFrom(this.Font);
    >>
    >>
    >> --
    >> I hope this helps,
    >> Steve C. Orr, MCSD, MVP
    >> http://SteveOrr.net
    >>
    >>
    >>
    >> <> wrote in message
    >> news:...
    >> > In a custom control, inherited from WebControl, I get a Font property
    >> > automatically. What's it's purpose. When I render text within the
    >> > control,
    >> > it's not rendered with the attributes of that font object. Do I have
    >> > to
    >> > read the attributes of the font object and render each one within a
    >> > font
    >> > tag
    >> > manually?
    >> >
    >> > I'm overriding the RenderBeginTag, RenderContentes and RenderEndTag
    >> > methods.
    >> > They render a hierarchy of tables and divs, but I want the innertext of
    >> > the
    >> > innermost element to be rendered in the font selected in the properties
    >> > dialog.
    >> >
    >> > What am I missing?
    >> >
    >> > Thanks.
    >> >
    >> > Jerry
    >> >
    >> >

    >>
    >>

    >
    >
    Steve C. Orr [MVP, MCSD], Feb 10, 2006
    #4
  5. Hi Jerry,

    The "Font" property is one of the buildin styles collection of WebControl
    class. And normally for simple controls like TextBox, Label, such
    properties will be applied to control during the RenderBeginTag method(by
    apply the attributes into the Render). However, if we're developing some
    composite controls which will have sub controls or complex control
    hierarchy, we may need to manually apply the Font setting to the certain
    sub control in our custom control's code.(e.g in the PreRender event)

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Feb 13, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl Hungus

    Font class, external font files question

    Karl Hungus, Feb 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    511
    Karl Hungus
    Feb 4, 2004
  2. =?Utf-8?B?Tmlja3k=?=
    Replies:
    2
    Views:
    691
    Matt Berther
    Feb 20, 2005
  3. Michael Glavitsch
    Replies:
    1
    Views:
    741
    Roedy Green
    Jul 15, 2003
  4. Nick Spinel
    Replies:
    0
    Views:
    918
    Nick Spinel
    Jul 25, 2003
  5. mttc
    Replies:
    2
    Views:
    2,364
    Roedy Green
    Jul 3, 2009
Loading...

Share This Page