Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Getting HTML of Web User Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ITistic - 02 Oct 2007 04:45 GMT
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!
Alexey Smirnov - 02 Oct 2007 08:00 GMT
> 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
[quoted text clipped - 6 lines]
> 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()
Steve C. Orr [MCSD, MVP, CSM, ASP Insider] - 02 Oct 2007 08:31 GMT
Use the RenderControl method of the control.
Here's a complete article detailing how to email the rendered HTML of a web
control:
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

Signature

I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

> 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
[quoted text clipped - 6 lines]
> way. Any ideas you have would be greatly appreciated. Thanks in
> advance for your time and effort!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.