converting ascx to dll ?

M

miladhatam

hi
i've made a Web User Control (ascx file)
i want to convert it to "dll" file and put it in my toolbox
ofcourse i 've built my project but the dll of my Web User Control is
useless
how can i do it with VS 2008?
 
C

Cowboy \(Gregory A. Beamer\)

There is no automagic way to convert from ASCX to server control. And I am
not sure there is a tool out there, as the permeatations of what you might
accomplish are huge.

The way to do it is to look at the rendered output and create a render
method. Any helper methods, that do not touch controls, can be copied
verbatim from the code behind to the class. You then have to compile and
test, as it is a UI component. Once you do this a few times, you will be
well versed enough to create server controls without the intermediate user
control stage.

I wish I had a better answer and would love if someone could say Product X
does this. Good luck!
 
L

Louis Somers

This was one of the pitfalls I first fell in when starting with ASP.Net!

Usercontrols, or pages, or anything with an aspx / ascx file cannot be used
as a base class to inherit from!

My current conception about these files (I'm presuming and assuming quite
allot now) is as follows: The as?x file is dynamically compiled by the ASP
runtime when requested and somehow inherits from the compiled dll (which
includes the code-behind stuff). It's simply a static file that sets up an
hyrarchy of controls and sets their initial properties.

You cannot see it as a winforms usercontrol, wich is simply a class from
which you can inherit. For ASP, if you want to inherit from a basic
usercontrol, you are not able to create it using the designer, but will have
to do everything in code, inheriting from Control or so, not using any as?x
xml stuff.
 
B

bruce barker

this can be done with a combination of using the aspnet_compiler and
aspnet_merge. you will end up with really ugly assembly names, but it will
work. you should study these tools and understand how the aspnet_compiler
builds and names output files. (adds a hash based on directory name to
assembly). you can also use the webdeployment project, and just find the dll
that represents the user control.

a better longterm approach might be to compiel you site to a single dll, and
use reflector to extract the code generated by asp.net compielr for the ascx.
use this to build a real control.


-- bruce (sqlwork.com)
 

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

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top