Adam Smith said:
Hi John,
thanks for replying...
Heres what I'm trying to acheive.
This is for an e-mail marketing newsletter. The user enters the product
ID's in the textboxes at the top of the page (along with layout and some
other details). These are sent to multiple instances of the user control
which displays the product in question. This is all graphically displayed
in a Panel, so the user can see what the e-mail newsletter will look like.
This all works fine.
The Panel's html is grabbed via a htmltextwriter and deposited in the
textarea, this is so any manual modifications can be made and later saved to
a database for sending at a later date.
This works partially, the user controls HTML is not being grabbed. I
presume this is due to the calling of them happening after I grab the panels
html.
So where in the page life cycle do I need to grab the panels html in order
to include the html of the user controls?
Adam,
HTML is only generated in the Render method. The output of the user controls
simply does not exist before the Render method of the user controls has
executed.
At the same time, you have the problem that you want to fill the textarea on
the same page with HTML generated from controls on the page. I don't think
you're going to get anywhere with that. If I were you, I'd look into some
client-side manipulations. HTML is all that the client side sees, so the
HTML will certainly be there for the client to manipulate.
One way you could do this would be to have an Edit button associated with
each panel. When the button is clicked, client-side script could copy
panel.InnerHTML into the TextArea. You could also pop up a separate window
with the HTML if you wanted.
If you can limit yourself to Internet Explorer, you could use some of the
content editing features of IE. See
http://msdn.microsoft.com/library/d.../browser/mshtml/mshtml_editing_node_entry.asp for far too much information on this. Also, my
favorite "Custom Controls" book has an example ASP.NET HTMLEdit control in
chapter 13. See "Developing Microsoft® ASP.NET Server Controls and
Components" from Microsoft Press, by Nikhil Kothari and Vandana Datye
(
http://www.microsoft.com/mspress/books/5728.asp). Source code is provided.
I hope this helps you some. If it does, be sure to let us know - I needed
something like this at one time but punted because I couldn't get it done
quickly enough.