User control to custom control

J

JJ

Whats the best way to convert a user control to a custom server control?

i.e. I created a .aspx control using the designer to create the look of the
control. I now want to use this in other projects and compile it as a dll.
However, I understand that I now need to create the controls interface
elements via code. Is there a way to easily translate a previously created
interface to be created by code?

Not sure I am making myself very clear but hopefully someone will be able to
understand...
Thanks
JJ
 
S

Steven Cheng[MSFT]

Thanks for Peter's input.

Hi JJ,

So far for template based control (ascx usercontrol and ASPX page), there
hasn't any good means to directly convert them into custom control.
However, I think the following means is worth a try:

Since ASP.NET will dynamically compile ASPX or ascx into dynamic class at
runtime, you can manually use precompilation to precompile the website and
get the precompiled assemblies(you can choose non-updatable so that ascx ,
aspx will also be precompiled into assembly). After that you can use
reflector utility to inspect the precompiled code which should contains the
code that programmatically construct the ascx/aspx UI. Of course, you need
to modify them since those dynamically generated code is not quite human
readable, but can be used as a reference. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
S

Steven Cheng[MSFT]

Hi JJ,

Have you got any progress or do you have any further questions? If so,
please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: (e-mail address removed) (Steven Cheng[MSFT])
Organization: Microsoft
Date: Tue, 30 Oct 2007 04:17:48 GMT
Subject: RE: User control to custom control
 

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

Top