Creating A Custom HtmlControl

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Jul 23, 2009.

  1. 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.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Jul 23, 2009
    #1
    1. Advertising

  2. "Nathan Sokalski" <> wrote in
    news:OndtgK#:

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Jul 24, 2009
    #2
    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. Paul
    Replies:
    1
    Views:
    3,226
    bruce barker
    Aug 4, 2003
  2. =?Utf-8?B?VmljdG9y?=

    WebControl vs. HtmlControl

    =?Utf-8?B?VmljdG9y?=, Mar 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    468
    =?Utf-8?B?VHUtVGhhY2g=?=
    Mar 3, 2004
  3. Tim Mulholland

    Make HtmlControl invisible

    Tim Mulholland, Aug 10, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    6,371
    Tim Mulholland
    Aug 13, 2004
  4. Nathan Sokalski

    Creating A Custom HtmlControl

    Nathan Sokalski, Jul 23, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    569
    Gregory A. Beamer
    Jul 24, 2009
  5. Chris
    Replies:
    1
    Views:
    220
    Chris Simmons
    Nov 6, 2003
Loading...

Share This Page