Email contents of page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to put into the body of an email, the entire contents of a
aspx page....with form fields filled out

I know I could go through and get the values of all of the textboxes, radio
button lists, etc, and format the body of my email, but it would be very
convenient if I could just have the email contain exactly what the page looks
like because the page is quite large.

I've tried to do a Page.RenderControl(htmlTextWriter); ...this does acutally
work, and I can get the page's rendered HTML into a StringBuilder variable,
but when the page posts back I get a "Page can only have one form runat
server....error.

So can this be done??

Thanks in advance!


John Scott.
 
Hi John,

Does the page work if you don't email it? I'd imagine it doesn't. You
probably have 2 forms on the page which ASPX can't handle.

Just my 2 pence,
Jan
 
The page loads fine and I can fill out all the form values...the problem
exists when I click on a "Email Form" button....that's when the RenderControl
method is called and when the page posts back it acutally has two form tags
in the posted data.
 
Hi John,

Do not let the page post back. After you call RenderControl, redirect the
page to another page. You should not invoke RenderControl twice.

I believe this should work.
 
I don't want to redirect to a different page, because I want to be able give
the user the ability to print the page either before OR after emailing the
form....

Redirecting would be the easy way out...but it won't work for me in the case.
 
Hi John,

One question - why do you want to do a post back for printing? You could
handle this at the client side itself right?

This would make printing an independent task, which would also do away with
the RenderControl issue.

--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.msmvps.com/rakeshrajan/
 
The printing is actually done on the client-side...

The ideal situation is to allow the user to print out what ever they have
filled out...as well as be able to email the contents of the page....it
shouldn't matter to them which order they do it.

Does that make sense??

Thanks,

John Scott.
 
Hmm...that is true.

The issue is you need to get the rendered contents (with user input) at the
server side, and re-display the same page so that the user may print it. This
is so that the user may do either printing or e-mailing in any order.

If you had somehow made printing always before e-mailing, then it could have
been simpler.

I am not getting any solutions to satisfy both requirements rt now :(. Let
me think it over...

--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.msmvps.com/rakeshrajan/
 
That's exactly what I need...I also thought that in a worst-case scenario I
could just make an alert box pop up letting the user know that they need to
print the form before submitting it...kind of a lame solution, but it would
make things a lot easer. Please let me know if you have any other ideas.

Thank you for your quick reponses too!!
 
Back
Top