473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting HTML of Web User Control

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!

Oct 2 '07 #1
2 1147
On Oct 2, 5:45 am, ITistic <sh...@itistic.comwrote:
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()

Oct 2 '07 #2
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

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

"ITistic" <sh***@itistic.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
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!
Oct 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mohan | last post by:
Hi All, I am using web browser control in a VB 6.0 client server application to print reports. I am writing the report into a HTML file and displays the report to the user using the code,...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
2
by: Chad | last post by:
In our application, I would like to send out HTML mail. TO do so, I must do something like this: Mail.Body = <raw HTMLTEXT String> Hence, I would like to know how to get the HTML text for Web...
3
by: PJ6 | last post by:
When I have client-side script like this - document.forms.submit('test') how do I access, from server-side code, the value I put in the submit method? Also, is it possible to get the...
3
by: Sridhar | last post by:
Hi, I am having a trivial problem which is not that important but I would like to know if I am missing something. I have created a user control. When I drag the user control into one of the web...
8
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB"...
1
by: RSH | last post by:
I have a situation where I have a user control (Called TopOrangeMenu) that has an Hidden HTML Field called "txtU" I am trying to get at the value of that hidden field control from within the...
6
by: Samuel Rhodes | last post by:
Hi I am trying to write a code snippet that would display a '?' sign on the top left of a control. I do not want to hard code the positioning of the DIV which will contain that '?'. Is it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.