WYIWYG way for creating Custom Controls

  • Thread starter Thread starter Abdo Haji-Ali
  • Start date Start date
A

Abdo Haji-Ali

Previously I used to create user controls if I wanted to use a
specific set of controls in multiple pages, however I want to deploy
my control in other applications so I thought of creating custom
controls.
Only problem is that I'm used to designing my controls in a WYSIWYG
(tm) way (i.e. using the designer and writing HTML tags). The only way
I found to create custom controls was to create controls dynamically,
set their properties and render them all using pure code, something I
find really annoying.

So my question is: Is there a way I can create custom controls using a
designer and HTML tags only (i.e. without using so many writer.Write()
statements).

Thanks,
Abdo Haji-Ali
Programmer
TechnoLead
 
Hi,
there is a way how to get "wysiwyg support when creating custom controls"
but it is not as easy as expected. First you need to inherit your control
from TemplateControl. Template control offers nice method called
ParseControl. You can put any well formated user control to this script and
it will create instance of user control class for you. Any ascx file can be
embedded as resource to your class library. So you can think about following
approach:

1. create new control library
2. in this library create new control by inheriting from TemplateControl
3. embedded user control (ascx) file to your control library
4. in Init handler of your custom control load resource from dll and create
user control instace by calling ParseControl
5. add created user control to controls collection

I have seen nice article about this somewhere, but I am not able to find it
now.

Regards,
Ladislav
 
Back
Top