944,075 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 8896
  • ASP.NET RSS
May 19th, 2006
0

Email Web Page Content

Expand Post »
Hi all,

I hav an application running in ASP.Net using VB. I hav two textboxes which carries user's input and a button. On Click of this button, the values in the textboxes will be added and be displayed in a label in a new window. I hav declared a variable to carry the result and display it in the label. Now, in the new window i hav a button to email the page content and the result label which is in a panel. I'm using the below code to email the new window content.

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim SB As New StringBuilder()
Dim sw As New StringWriter(SB)
Dim htmlTW As New HtmlTextWriter(sw)
Label1.RenderControl(htmlTW)

Dim printlabel As String = SB.ToString()

'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("mysathia@streamyx.com")
mail.To.Add("sathia.m@dotw.com")
mail.IsBodyHtml = True

'set the content
mail.Subject = "Test Message"
mail.Body = printlabel

'send the message
Dim smtp As New SmtpClient("smtp.tm.net.my")
smtp.Send(mail)
Response.Write("Message Sent")
End Sub

Query: When I email the new window, i can only get the result label displayed. I want the result label to be displayed with the panel. Can anyone help me on this.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sathiya is offline Offline
6 posts
since May 2006
Jun 15th, 2006
0

Re: Email Web Page Content

Hi.

Try exchanging Label1.RenderControl(htmlTW) with Page.RenderControl(htmlTW).
This will give you the entire page including all controls.

Or, you can put the code inside a <div> tag like this:
<div id="divPanel" runat="server">
<your code>
</div>

And then use divPanel.RenderControl(htmlTW).
Reputation Points: 87
Solved Threads: 128
Practically a Master Poster
Oxiegen is offline Offline
652 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Problem with javascript variable and hidden input
Next Thread in ASP.NET Forum Timeline: Cross-Page PostBack with grouped RadioButtons





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC