0

There is an ASP.NET page that searches my database and inserts the results in a RepeaterList. The page is rendered for me, but I need to save the content that has been rendered into a variable. The user should be able to send the rendered content in an e-mail by clicking a button. How do I do this?

3
  • You want to send the entire page as an HTML e-mail? Do I understand you correctly? Commented Oct 20, 2011 at 19:38
  • yeah, is it! i want to get html to inser in my email body! Commented Oct 20, 2011 at 19:44
  • Couldn't you use jquery and essentially assign the html content to a variable that can be passed around? Commented Oct 20, 2011 at 19:44

2 Answers 2

2

If you want to email the HTML contents of the repeater, you can do something like this:

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);    
Repeater1.RenderControl(oHtmlTextWriter);

string repeaterHtml = oStringWriter.ToString();
Sign up to request clarification or add additional context in comments.

Comments

1

Probably the quickest way I've done so would be to do a postback on the email button, override Render and send your email there if the button had been clicked.

Rick Strahl has an old, but good example.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.