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, Jul 23, 2009
    #1
    1. Advertisements

  2. 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, Jul 24, 2009
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.