impossible or not: dynamically embedding a user control in the middle of a string?

G

Guest

I'm thinking of a content management scenario in which you have a news
article, and then a photograph and caption that you want to appear in the
middle of the article text. The text of the article is a string pulled from
a database -- let's call it ArticleText.

I'm wondering if it is possible or not possible to have a user control
dynamically placed and rendered in the middle of BodyText. What approach
might you take?

-KF
 
S

Steven Cheng[MSFT]

Hello KF,

From your description, you want to dynamically create a usercontrol and
embed it into a large text string paragragh(retrieved from database),
correct?

Based on my experience, it depend on whether the usercontrol can be embeded
in a fixed place in your text paragragh. For example, if the usercontrol is
always embeded in the middle of your text pragraph, you can divide the text
string into two substrings and bound on the page(databinding) into two
place, thus, you can put a placeholder between them, and dynamically load
the usercontrol into the placeholder at runtime.

If this is not the case, I'm afraid we can not dynamically insert a
usercontrol or other ASP.NET server control into discretionary postion in a
plain text paragraph.

BTW, do you think it is possible to replace the usercontrol with an html
image element? (<img src=.... />) If so, you can consider insert a <img>
tag into your text paragraph and let the image link to a dynamic generated
image stream. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

The binding idea is creative and will probably suit my needs. Thank you very
much for the suggestion.

-KF
 

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,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top