Adding User Controls at Runtime

G

Guest

Hi

I am upgrading an ASP site where the content is being pulled from a database. On the ASP site the DB content included form tags and other html controls. I want to replace these with a user control but am not sure how to get the controls rendered correctly at runtime. If I output the content as text, it will not realise that the tags are actually user controls and will just render them as text as this content will not be parsed

Essentially I think I need to sort of re-load the page or in some way get the server to re-parse it? Does anyone have any ideas on how to do this. I am aware of the LoadControl command but to use this requires me to do a manual parsing of the DB content using string manipulation or regular expressions both of which are fairly dodgy. Any better ideas

Thanks
 
H

Hans Kesting

Linda Wienholt said:
Hi,

I am upgrading an ASP site where the content is being pulled from a
database. On the ASP site the DB content included form tags and other html
controls. I want to replace these with a user control but am not sure how
to get the controls rendered correctly at runtime. If I output the content
as text, it will not realise that the tags are actually user controls and
will just render them as text as this content will not be parsed.
Essentially I think I need to sort of re-load the page or in some way get
the server to re-parse it? Does anyone have any ideas on how to do this. I
am aware of the LoadControl command but to use this requires me to do a
manual parsing of the DB content using string manipulation or regular
expressions both of which are fairly dodgy. Any better ideas?

You could use a <div id="..." runat=server> in your page, declare it as
HtmlGenericControl
and set the InnerHtml of that control.

HOWEVER:
- the asp.net page already contains a <form> tag, and you cannot nest
<form>'s
- you can't access input fields in your content in a ".net way", only read
the results with Request[]
- the html needs to be "well-formed": you can't open a tag in one div, and
then close
it in another.


Hans Kesting
 

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,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top