Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > send entire page by email

Reply
Thread Tools

send entire page by email

 
 
Martin
Guest
Posts: n/a
 
      04-13-2005
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.



 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      04-13-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
>
>
>



 
Reply With Quote
 
 
 
 
Lau Lei Cheong
Guest
Posts: n/a
 
      04-13-2005
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]" <(E-Mail Removed)> 秎ン
news:up%(E-Mail Removed) い级糶...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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.
> >
> >
> >

>
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      04-13-2005
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" <(E-Mail Removed)> wrote in message
news:%23Xr%(E-Mail Removed)...
> 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]" <(E-Mail Removed)> 秎ン
> news:up%(E-Mail Removed) い级糶...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>> > 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.
>> >
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      04-13-2005
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]" <(E-Mail Removed)> wrote in message
news:up%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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.
>>
>>
>>

>
>



 
Reply With Quote
 
Lau Lei Cheong
Guest
Posts: n/a
 
      04-13-2005
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 <aspanel> 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" <(E-Mail Removed)> 秎ン
news:(E-Mail Removed) い级糶...
> 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" <(E-Mail Removed)> wrote in message
> news:%23Xr%(E-Mail Removed)...
> > 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]" <(E-Mail Removed)> 秎ン
> > news:up%(E-Mail Removed) い级糶...
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:%(E-Mail Removed)...
> >> > 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.
> >> >
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      04-13-2005
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" <(E-Mail Removed)> wrote in message
news:OrBtEC%(E-Mail Removed)...
> 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 <aspanel> 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" <(E-Mail Removed)> 秎ン
> news:(E-Mail Removed) い级糶...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%23Xr%(E-Mail Removed)...
>> > 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]" <(E-Mail Removed)> 秎ン
>> > news:up%(E-Mail Removed) い级糶...
>> >> 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" <(E-Mail Removed)> wrote in message
>> >> news:%(E-Mail Removed)...
>> >> > 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.
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Lau Lei Cheong
Guest
Posts: n/a
 
      04-13-2005
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" <(E-Mail Removed)> 秎ン
news:%23245EM%(E-Mail Removed) い级糶...
> 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" <(E-Mail Removed)> wrote in message
> news:OrBtEC%(E-Mail Removed)...
> > 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 <aspanel> 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" <(E-Mail Removed)> 秎ン
> > news:(E-Mail Removed) い级糶...
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:%23Xr%(E-Mail Removed)...
> >> > 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]" <(E-Mail Removed)> 秎ン
> >> > news:up%(E-Mail Removed) い级糶...
> >> >> 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" <(E-Mail Removed)> wrote in message
> >> >> news:%(E-Mail Removed)...
> >> >> > 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.
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
refreshing control data on a page, without the entire page re-loading Milsnips ASP .Net 1 05-16-2005 10:35 AM
Transferring an entire outlook email to another computer? John Computer Information 0 02-08-2005 12:25 AM
Email Entire Webform =?Utf-8?B?TXJNaWtl?= ASP .Net 1 01-11-2005 07:03 PM
HowTo:? open email client to send email Peter ASP .Net 0 07-01-2003 04:58 PM



Advertisments