Having a UserControl returned in a string from another UserControl to be rendered

S

SlimFlem

I hope this makes sense.

Here is what I am attempting. I have an inital generic aspx page that
has one custom tag:

<web:site id=webSite runat=server/>

When this control evaluates, it will return a small amount of Html with
another custom control tag inside this html. For example:

<table>
<tr>
<td><web:page id=webPage runat=server/></td>
</tr>
</table>

In turn, this web:page control will have multiple other custom tags
called web:content. When asp.net renders this, only the initial custom
control I have embedded in the generic aspx page actually renders. The
web:site tag renders with the web:page custom control tag showing in
the rendered page source as plain text, it was never rendered.

What I need is a way to tell asp.net to render any custom control tags
I spit out inside text/html strings and have this repeat down thru a
series of controls.

How do I tell asp.net to essentially "re-render" the page. Hopefully
someone has done something similar and I am speaking clearly.

Thanks.
 
P

Peter Rilling

I do not think you can do that. Once the page has loaded, all the controls
have been parsed and processed.

Having said that, you can dynamically load controls using the LoadControl
method and add it to the Controls collection, but once ASP.NET has finished
parsing the document, it will not parse it anymore.

Maybe your goal does not fit with a proper design. What specifically are
you trying to do and maybe I can offer a better alternative?

From your small information below, maybe a better solutions would be to
constrain your top-level control even more by requiring that it return an
actual WebControl (or something) that can then be added to the Controls
collection at the proper place.

I am always cautions to allow my code to return data that cannot be
validated for correctness. For instance, by allowing any string to be
returned, you have no idea what will be returned, while if you return a
WebControl instance, then you know that it can be rendered.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top