By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

send entire page by email

P: n/a
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the entire
contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction to
achieving this.

many thanks in advance.

cheers

martin.

Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

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


"Martin" <ma*******************@martinz.co.nz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the
entire contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction
to achieving this.

many thanks in advance.

cheers

martin.

Nov 19 '05 #2

P: n/a
Actually, emailing the content produced by Page.Render() will do the job if
the page you want to email is the page itself. And it would be a lot
simpler.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> 秎ン
news:up***************@TK2MSFTNGP10.phx.gbl い级糶...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

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


"Martin" <ma*******************@martinz.co.nz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the
entire contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction to achieving this.

many thanks in advance.

cheers

martin.


Nov 19 '05 #3

P: n/a
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Me.Render(htmlWriter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Actually, emailing the content produced by Page.Render() will do the job
if
the page you want to email is the page itself. And it would be a lot
simpler.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> 秎ン
news:up***************@TK2MSFTNGP10.phx.gbl い级糶...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

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


"Martin" <ma*******************@martinz.co.nz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> I have a standard aspx page (form) that contains a few user controls.
> Upon form submission the page is validated.
> If validation passses then a text based email is sent.
> This is all working fine, however what I would like to do is sent the
> entire contents of the posted back page as a HTML email.
>
> Is this possible and if so could somebody point me in the right direction > to achieving this.
>
> many thanks in advance.
>
> cheers
>
> martin.
>
>
>



Nov 19 '05 #4

P: n/a
Hi steve,

I look at the 4guys article, this seems to work fine if the control is a
datagrid.
If I make my own user control and put on instance of it on a page (called
SimpleControl1)
The user control only has a single text box on it

and use the following code

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
SimpleControl1.RenderControl(htmlWriter)

I get an error when I try to do a post back (the above code is in a button
on a PAGE not the user control) saying that

"Control 'SimpleControl1_TextBox1' of type 'TextBox' must be placed inside a
form tag with runat=server"

I am not quite sure why this does not happen with the datagrid in 4guys
example.

If you could offer any advice it would be appreciated.

ideally I would like to send the output of the entire page (including all
user controls).
perhaps I will have to use a third party componenet.
cheers

martin.


"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:up***************@TK2MSFTNGP10.phx.gbl...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

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


"Martin" <ma*******************@martinz.co.nz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the
entire contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction
to achieving this.

many thanks in advance.

cheers

martin.


Nov 19 '05 #5

P: n/a
I've also encountered your problem, it's thought to be the case when
Page.Render() render the page twice and counted the page's form tag twice.
But since my form is actually a report, I just hide the user-input
parts(i.e.: the whole<form runat="server"></form>) in a <asp:panel> and hide
it before the mail function's Page.Render() calls. Since everything inside a
Panel with .Visible set to false won't render, it won't case problem.

"Martin" <ma*******************@martinz.co.nz> 秎ン
news:ug**************@TK2MSFTNGP12.phx.gbl い级糶...
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Me.Render(htmlWriter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Actually, emailing the content produced by Page.Render() will do the job
if
the page you want to email is the page itself. And it would be a lot
simpler.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> 秎ン
news:up***************@TK2MSFTNGP10.phx.gbl い级糶...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

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


"Martin" <ma*******************@martinz.co.nz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> I have a standard aspx page (form) that contains a few user controls.
> Upon form submission the page is validated.
> If validation passses then a text based email is sent.
> This is all working fine, however what I would like to do is sent the
> entire contents of the posted back page as a HTML email.
>
> Is this possible and if so could somebody point me in the right

direction
> to achieving this.
>
> many thanks in advance.
>
> cheers
>
> martin.
>
>
>



Nov 19 '05 #6

P: n/a
yes I see that your work around would work if you didn't need to get the
user input.
But in my case I actually want the user input so hiding the entire form in
an asp panel is not an option.

I am hoping to be able to retrive the HTML generated from the "re render"
event but I have been unsuccessful at present.

thanks for your help though.

cheers

martin.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Or****************@TK2MSFTNGP12.phx.gbl...
I've also encountered your problem, it's thought to be the case when
Page.Render() render the page twice and counted the page's form tag twice.
But since my form is actually a report, I just hide the user-input
parts(i.e.: the whole<form runat="server"></form>) in a <asp:panel> and
hide
it before the mail function's Page.Render() calls. Since everything inside
a
Panel with .Visible set to false won't render, it won't case problem.

"Martin" <ma*******************@martinz.co.nz> 秎ン
news:ug**************@TK2MSFTNGP12.phx.gbl い级糶...
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Me.Render(htmlWriter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> Actually, emailing the content produced by Page.Render() will do the
> job
> if
> the page you want to email is the page itself. And it would be a lot
> simpler.
>
> "Steve C. Orr [MVP, MCSD]" <St***@Orr.net> 秎ン
> news:up***************@TK2MSFTNGP10.phx.gbl い级糶...
>> You can email a page by using the WebRequest and MailMessage classes.
>>
>> Here are a couple examples:
>> http://www.aspalliance.com/stevesmit...ailwebsite.asp
>> http://aspnet.4guysfromrolla.com/articles/091102-1.aspx
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>>
>>
>> "Martin" <ma*******************@martinz.co.nz> wrote in message
>> news:%2****************@TK2MSFTNGP15.phx.gbl...
>> > Hi,
>> >
>> > I have a standard aspx page (form) that contains a few user
>> > controls.
>> > Upon form submission the page is validated.
>> > If validation passses then a text based email is sent.
>> > This is all working fine, however what I would like to do is sent
>> > the
>> > entire contents of the posted back page as a HTML email.
>> >
>> > Is this possible and if so could somebody point me in the right
> direction
>> > to achieving this.
>> >
>> > many thanks in advance.
>> >
>> > cheers
>> >
>> > martin.
>> >
>> >
>> >
>>
>>
>
>



Nov 19 '05 #7

P: n/a
Here's an article on how to disable form validation:
http://msdn.microsoft.com/msdnmag/is...d/default.aspx

I've not tried it, but you may take a look.

I suspect that deleting all runat=server from the page may also work,
because it's known that the input tags will preserve it's content even if
you don't do anything on it to preserve it. Just that don't know it's by the
client-side or server-side. If it's done by server-side, it'll work and you
can still access the form values through Response.Form[].

"Martin" <ma*******************@martinz.co.nz> 秎ン
news:%2******************@TK2MSFTNGP10.phx.gbl い级糶...
yes I see that your work around would work if you didn't need to get the
user input.
But in my case I actually want the user input so hiding the entire form in
an asp panel is not an option.

I am hoping to be able to retrive the HTML generated from the "re render"
event but I have been unsuccessful at present.

thanks for your help though.

cheers

martin.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Or****************@TK2MSFTNGP12.phx.gbl...
I've also encountered your problem, it's thought to be the case when
Page.Render() render the page twice and counted the page's form tag twice. But since my form is actually a report, I just hide the user-input
parts(i.e.: the whole<form runat="server"></form>) in a <asp:panel> and
hide
it before the mail function's Page.Render() calls. Since everything inside a
Panel with .Visible set to false won't render, it won't case problem.

"Martin" <ma*******************@martinz.co.nz> 秎ン
news:ug**************@TK2MSFTNGP12.phx.gbl い级糶...
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Me.Render(htmlWriter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> Actually, emailing the content produced by Page.Render() will do the
> job
> if
> the page you want to email is the page itself. And it would be a lot
> simpler.
>
> "Steve C. Orr [MVP, MCSD]" <St***@Orr.net> 秎ン
> news:up***************@TK2MSFTNGP10.phx.gbl い级糶...
>> You can email a page by using the WebRequest and MailMessage classes. >>
>> Here are a couple examples:
>> http://www.aspalliance.com/stevesmit...ailwebsite.asp >> http://aspnet.4guysfromrolla.com/articles/091102-1.aspx
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>>
>>
>> "Martin" <ma*******************@martinz.co.nz> wrote in message
>> news:%2****************@TK2MSFTNGP15.phx.gbl...
>> > Hi,
>> >
>> > I have a standard aspx page (form) that contains a few user
>> > controls.
>> > Upon form submission the page is validated.
>> > If validation passses then a text based email is sent.
>> > This is all working fine, however what I would like to do is sent
>> > the
>> > entire contents of the posted back page as a HTML email.
>> >
>> > Is this possible and if so could somebody point me in the right
> direction
>> > to achieving this.
>> >
>> > many thanks in advance.
>> >
>> > cheers
>> >
>> > martin.
>> >
>> >
>> >
>>
>>
>
>



Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.