Hi Rob,
I'm copying here my previous response I just wrote to a similar thread:
----
I tackle this "resizing and moving" deriving from Control, about a year and
half ago, just as an experiment while learning how the design-time support
worked.
The main issue is that the provided designers, when it comes to moving and
resizing were built for handling with WebControl-derived classes only, you
can notice that looking at all the explicit checks that ControlDesigner
makes looking if its designing a WebControl-derived class. This sounds
pretty logical also, as WebControl offers the minimum required
functionallity that is needed in order to be moved and resized while Control
doesn't provide that.
That said, you *could* actually make some of this stuff work for a
Control-derived class. I remember having coding a Control-derived class that
could be resized and it worked okay. But the additional code required isn't
worth it when compared to inheriting from WebControl (even if you may be
inheriting some stuff you don't really want). After giving it a shot, I've
always recommended several times in many posts to inherit from WebControl in
order to get this funcionallity.
btw, it has been publicy said that vNext will include some kind of
intermeditate control between WebControl and Control just to provide this
functionallity.
-----
--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
[url]http://obies.com/vga/blog.aspx[/url]
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
"Rob Mayo" <Rob.MayoWestonSolutions.com> wrote in message
news:emS3zLWTDHA.1556TK2MSFTNGP10.phx.gbl...
I saw the following post on dotnet24x7.com. Usually Victor Garcia Aprea has
been pretty helpful.
I have a similar issue. I WANT to derive from control, not webcontrol
because I don't want all those other properties, only mine. I'm just seeking
a little clarification and perhaps a code sample. I've already Implemented
IAttributeAccessor. (I got that from microsoft.com when I looked at the
class definition for webcontrol) Now what?
If I understand this correctly, I need to create 2 properties; 1 called
Style As System.Web.UI.WebControls.Style, 1 called CssStyleCollection As
System.Web.UI.CssStyleCollection.
The other way I understood this portion was to create 1 property; Style As
System.Web.UI.CssStyleCollection
I already have my own properties set up for Height, Width, and TabIndex
What do I do with the AttributeCollection? Do I make that a public property,
or is it just for internal use to be accessed by the GetAttribute and
SetAttribute methods?
Once I implement the style property, will my control automagically be able
to pe positioned? If not, then what code do I need to implement that?
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
Hi.
Because of my project's requirements, I'm building webcontrols deriving
directly from the
System.Web.UI.Control class and not from the
System.Web.UI.WebControls.WebControl class. I cannot change this.
My problem is that at design time I'm not able to move my controls around on
the form or resize them.
How do I provide this functionality, which is available when I inherit from
the Webcontrol class ?
Is there an interface to be omplemented or method to be overriden ?
Thanks a lot!
Sergio
Victor Garcia Aprea [noobiesspam.com]
Hi Sergio,
You should add to your control the built-in support for Style property that
the WebControl already implements. If your control support this, you will be
able to move and resize it using the IDE and also it will display as
expected when it is rendered. You need to add a basic Style and
CssStyleCollection properties to hold your control style, also you may want
to expose additional properties for particular settings (ex. Width, Height,
etc), you will need to have an AttributeCollection to hold your controls
attribute and inherit the IAttributeAccesor interface. It will require some
coding. Can you tell what is the specific reason that you are not allowed to
inherit from WebControl?
HTH,
-Victor.
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
Thanks for any help
-Rob
Bookmarks