WYIWYG way for creating Custom Controls

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
 
G

Guest

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
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top