send mail with page-html-content

A

Alexander Widera

I have a page with the following code for example:

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1"
Debug="true"%>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
texttoview.Text = "this is the text";
}
</script>

<!--#include virtual="/templates/Head.aspx" -->
<title>Title of the page</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="texttoview" />
</form>
<!--#include virtual="/templates/Footer.aspx" -->



After this page is "generated", or better said the html-code of this page, I
want to send this html-code by email to someone.
How can i make this possible? On this page could be a button, which causes
the sending-process on click.

thank you for your help.
 
A

Alexander Widera

if I follow the manual on http://www.openmymind.net/FAQ.aspx?documentId=45 i
have a problem ... i "converted" it to C# and now it looks like this:

StringBuilder stringBuilder = new StringBuilder();
StringWriter stringWriter;
HtmlTextWriter htmlTextWriter;
try
{
stringWriter = new StringWriter(stringBuilder);
htmlTextWriter = new HtmlTextWriter(stringWriter);
user.RenderControl(htmlTextWriter);
}
finally
{
stringWriter.Close();
htmlTextWriter.Close();
}


Now there was the error at "user.RenderControl(htmlTextWriter);" or even
with "user" with capital u at the beginning.... the method is unknown...
so I changed "user" to "page" ... but now there is this error-message:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
.....
[HttpException (0x80004005): A page can have only one server-side Form tag.]



But there is only one form-tag .... I think it's wrong that i chose "page"
..... what is the right?

I dont know what to do....
 
K

Karl Seguin

I'll clean up the FAQ, it isn't very clear....

user was a user control, so you would do:

SomeControl someControl = Page.LoadControl("someControl.ascx")

and then do:

someControl.RenderControl(htmlTextWriter);


This is easier done on a UserControl than a Page, so i would suggest you
simply move the page's stuff into a user control.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Alexander Widera said:
if I follow the manual on http://www.openmymind.net/FAQ.aspx?documentId=45 i
have a problem ... i "converted" it to C# and now it looks like this:

StringBuilder stringBuilder = new StringBuilder();
StringWriter stringWriter;
HtmlTextWriter htmlTextWriter;
try
{
stringWriter = new StringWriter(stringBuilder);
htmlTextWriter = new HtmlTextWriter(stringWriter);
user.RenderControl(htmlTextWriter);
}
finally
{
stringWriter.Close();
htmlTextWriter.Close();
}


Now there was the error at "user.RenderControl(htmlTextWriter);" or even
with "user" with capital u at the beginning.... the method is unknown...
so I changed "user" to "page" ... but now there is this error-message:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
....
[HttpException (0x80004005): A page can have only one server-side Form tag.]



But there is only one form-tag .... I think it's wrong that i chose "page"
.... what is the right?

I dont know what to do....



Karl Seguin said:
Alexander:
Check out: http://www.openmymind.net/FAQ.aspx?documentId=45

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
A

Alexander Widera

thank you...
now it works

Karl Seguin said:
I'll clean up the FAQ, it isn't very clear....

user was a user control, so you would do:

SomeControl someControl = Page.LoadControl("someControl.ascx")

and then do:

someControl.RenderControl(htmlTextWriter);


This is easier done on a UserControl than a Page, so i would suggest you
simply move the page's stuff into a user control.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Alexander Widera said:
if I follow the manual on
http://www.openmymind.net/FAQ.aspx?documentId=45 i
have a problem ... i "converted" it to C# and now it looks like this:

StringBuilder stringBuilder = new StringBuilder();
StringWriter stringWriter;
HtmlTextWriter htmlTextWriter;
try
{
stringWriter = new StringWriter(stringBuilder);
htmlTextWriter = new HtmlTextWriter(stringWriter);
user.RenderControl(htmlTextWriter);
}
finally
{
stringWriter.Close();
htmlTextWriter.Close();
}


Now there was the error at "user.RenderControl(htmlTextWriter);" or even
with "user" with capital u at the beginning.... the method is unknown...
so I changed "user" to "page" ... but now there is this error-message:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
....
[HttpException (0x80004005): A page can have only one server-side Form tag.]



But there is only one form-tag .... I think it's wrong that i chose
"page"
.... what is the right?

I dont know what to do....



Karl Seguin said:
Alexander:
Check out: http://www.openmymind.net/FAQ.aspx?documentId=45

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


message
I have a page with the following code for example:

<%@ Page Language="C#" ContentType="text/html"
ResponseEncoding="iso-8859-1"
Debug="true"%>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
texttoview.Text = "this is the text";
}
</script>

<!--#include virtual="/templates/Head.aspx" -->
<title>Title of the page</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="texttoview" />
</form>
<!--#include virtual="/templates/Footer.aspx" -->



After this page is "generated", or better said the html-code of this
page,
I
want to send this html-code by email to someone.
How can i make this possible? On this page could be a button, which
causes
the sending-process on click.

thank you for your help.
 

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

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top