Rendering ASP User Controls By Reading Source from a file

F

Fadi.MM

Hi Guys,
I'm trying to create a library of ASP.NET user controls.
What i'm trying to do is to encapsulate all my controls in one library
(DLL) and re-using them in other projects. Everything is going fine as
long as the control is only a C# or VB class.
But when it comes to a .aspx based control, I'm not able to use it in
my client projects, of course because the server-side built-in controls
in the aspx (ASP.Textboxes, ASP.dropdown etc..) are not defined in the
client project.
In order to solve this, I have to add those controls one-by-one
programatically using mycontrol.Controls.Add(textbox etc..). This
solution is working fine. But i'm looking for better one:
I'm trying to use the .ascx source file, read it inside my control
class, and render it by overrding the control.render event. But the
server controls are not rendered. I tried to use the RenderChildren
sub, the Render and OnPreRender. but it's seems that all these subs are
working after the page is rendered. I'm getting the source of the .ascx
file written as HTML in the client page after I run it.
Does anybody have clue about this?

Thanks
Fadi
 
C

cbDevelopment

..NET takes the ASCX (and ASPX) code and converts it into a DLL at
runtime. Your ASCX/ASPX code literally inherits from your code-behind
file. If you take a look in C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
\Temporary ASP.NET Files after hitting your page for the first time, you
will see plenty of files that ASP.NET has made for you. Some of them are
the .VB/.CS files for your ASCX/ASPX pages. You can grab this code and
use it to make your DLL-only code library.

You may want to clean up that folder before looking for your code. It
tends to get very cluttered.

If you insist on reading from the ASCX files, you will need to make a tag
parser. Not overly difficult with Regex and all, but why reinvent the
wheel?

--
----
700cb Development, Inc.
http://www.700cb.net
..NET utilities, developer tools,
and enterprise solutions

(e-mail address removed) wrote in @z34g2000cwc.googlegroups.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,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top