473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Rendering ASP User Controls By Reading Source from a file

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

Mar 9 '06 #1
1 1422
..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

Fa*****@gmail.com wrote in news:1141910489.639235.243110
@z34g2000cwc.googlegroups.com:
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


Mar 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table...
3
by: David Whitney | last post by:
All: I have a control that renders a table. As the table is rendered, each row in the table is constructed by creating a run-time (dynamic) object that is derived from an HtmlTableRow. The row...
2
by: Mike Speak | last post by:
I have a user control that I want to use to render 4 menu items (retrieved from db) on the top of each of my asp.net pages. The user control defines a table, with one TR and one TD. Within the...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
5
by: Dave A | last post by:
I am writing an ASP.NET tool that will allow the client to create their own online froms. ie the client can add tect boxes, text, drop downs,etc with absolutely no technical skill what so ever....
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
2
by: Giedrius | last post by:
hi, i have an idea to make admin tool on home computer, that would generate html files using some kind of templates and database data and put these generated html files to public web server, witch...
4
by: AG | last post by:
Using VS2005. When I add a server control to a page in design view, it displays the following; Error Rendering Control = <control name> An unhandled exception has occurred. 'HelpVerb' could...
3
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.