Getting HTML of Web User Control

I

ITistic

In a project I have developed there is one Web User Control which we
use on 2 different web forms. In addition to using this control on
these web forms we now need to be able to send an email out with the
contents of this user control. How can I instantiate the user control
from code and gain access to the fully rendered HTML source so I can
place it into an email message. Is this possible? I've thought of a
rather dirty way of doing it -- just performing a web request to a
page that contains this control, but I'd rather not go about it this
way. Any ideas you have would be greatly appreciated. Thanks in
advance for your time and effort!
 
G

Guest

In a project I have developed there is one Web User Control which we
use on 2 different web forms. In addition to using this control on
these web forms we now need to be able to send an email out with the
contents of this user control. How can I instantiate the user control
from code and gain access to the fully rendered HTML source so I can
place it into an email message. Is this possible? I've thought of a
rather dirty way of doing it -- just performing a web request to a
page that contains this control, but I'd rather not go about it this
way. Any ideas you have would be greatly appreciated. Thanks in
advance for your time and effort!

Dim sb as New StringBuilder()
Dim sw as New StringWriter(sb)
Dim tw as New HtmlTextWriter(sw)

myControl.RenderControl(tw)

Dim html as String = sb.ToString()
 

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,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top