Creating A Custom HtmlControl

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I want to create a custom control that has a style and id attribute, but not
all the extra stuff that a WebControl has. I would think I would inherit
from either the HtmlControl HtmlGenericControl class, but this does not seem
to be working. I have written lots of controls in the past by inheriting
from the Control and WebControl classes, so I have written custom control
before, and I have managed to make a working version of my control by
inheriting from the Control class, but I want to find a way to avoid all the
extra work to add the style and id attributes that I should be able to get
by inheriting from another class. Thanks.
 
I want to create a custom control that has a style and id attribute,
but not all the extra stuff that a WebControl has. I would think I
would inherit from either the HtmlControl HtmlGenericControl class,
but this does not seem to be working. I have written lots of controls
in the past by inheriting from the Control and WebControl classes, so
I have written custom control before, and I have managed to make a
working version of my control by inheriting from the Control class,
but I want to find a way to avoid all the extra work to add the style
and id attributes that I should be able to get by inheriting from
another class. Thanks.

As it "costs" no more to create an ASP.NET Server control, I am not sure
why you want to jump through these hoops. Yes, you avoid the "extra"
stuff, but you can simply ignore it. you are not gaining a huge amount
of performance, if any, by going the more limited HTML route. And, if
you are going to market this control, you have greatly limited what can
be done with it.

That aside: As for a roadmap to doing it, try finding a similar control
already in the library and then use Reflector (free from RedGate) to
figure out what you have to include. To have this render properly, you
will have some attributes to set on the control. I would play with this
myself, but I see no use for it for my projects, at least not at
present.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top