473,657 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Contr ols.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 1433
..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\Micr osoft.NET\Frame work\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.c om wrote in news:1141910489 .639235.243110
@z34g2000cwc.go oglegroups.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.Contr ols.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
5277
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 (table.ID is TestTable) On .aspx page: <HeaderTemplate> <asp:Table ID="TestTable" runat="Server" /> </HeaderTemplate>
3
3024
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 has three HtmlTableCell objects, and each cell contains a single control added to the HtmlTableCell's Controls collection. The basic table renders correctly, but the controls within the HtmlTableCell objects do not; the cells are just empty. (Just...
2
4724
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 TD I have a placeholder defined: <asp:PlaceHolder ID="categoriesPlaceHolder" Runat="server" /> In the code behind of the user control, on the Page_Load event I am retrieving data from db and adding controls to the placeholder as
3
2227
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 some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
5
2629
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. The form can then be deployed to their intranet. The form designer is somewhat WYSIWYG but it contains a heap of 'edit', 'delete' and reordering buttons that are not seen when the form is acutally being used. I would love to have a preview...
2
2578
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 good while and I'm getting really frustrated now! My problem is this - my custom controls periodically disappear from my
2
1769
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 doesn't have running asp.net, using ftp access. why i need so? because: 1) my project doesn't need to receive any data from browsing customers, it will be only company news, info about new products - so it's enough to have static html on...
4
9522
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 not be initialized. Details: 'False' could not be set on property 'Checked'. I have searched the web an only found one similar post where it was stated
3
2423
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 couple of the Firefox is munging up. So, on my information page there is a gridview in the content section of the page. The masterpage contains searching capabilities for the gridview. The masterpage has controls contained in a panel control,...
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.