Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Creating A Custom HtmlControl

Reply
Thread Tools

Creating A Custom HtmlControl

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      07-23-2009
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.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      07-24-2009
"Nathan Sokalski" <(E-Mail Removed)> wrote in
news:OndtgK#(E-Mail Removed):

> 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! |
*******************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating A Custom HtmlControl Nathan Sokalski ASP .Net Web Controls 1 07-24-2009 05:43 PM
Make HtmlControl invisible Tim Mulholland ASP .Net 5 08-13-2004 01:51 PM
WebControl vs. HtmlControl =?Utf-8?B?VmljdG9y?= ASP .Net 1 03-03-2004 02:51 PM
Why can't I make a custom control from System.Web.UI.HtmlControls.HtmlControl? Chris ASP .Net Building Controls 1 11-06-2003 04:18 PM
Modify InnerHtml of HtmlControl with JavaScript? Paul ASP .Net 1 08-04-2003 04:16 PM



Advertisments