469,943 Members | 2,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,943 developers. It's quick & easy.

User control to custom control

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
Oct 29 '07 #1
3 2186
"Best" way, dunno. But essentially you need to get the UI generation of the
UserControl ascx elements into the CustomControl's various Render methods.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"JJ" wrote:
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
Oct 29 '07 #2
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.

--------------------
>Subject: RE: User control to custom control
Date: Mon, 29 Oct 2007 09:43:00 -0700
>
"Best" way, dunno. But essentially you need to get the UI generation of
the
>UserControl ascx elements into the CustomControl's various Render methods.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"JJ" wrote:
>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
Oct 30 '07 #3
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: st*****@online.microsoft.com (Steven Cheng[MSFT])
Organization: Microsoft
Date: Tue, 30 Oct 2007 04:17:48 GMT
Subject: RE: User control to custom control
>
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.
Nov 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by BBM | last post: by
reply views Thread by Jeff Schaefer | last post: by
11 posts views Thread by John J. Hughes II | last post: by
3 posts views Thread by RichB | last post: by
4 posts views Thread by =?Utf-8?B?UmljaEI=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.