Using the Font property

G

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
 
S

Steve C. Orr [MVP, MCSD]

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);
 
G

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.
 
S

Steve C. Orr [MVP, MCSD]

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.
 
S

Steven Cheng[MSFT]

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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top