Getting HTML result of Custom User Control for use in an email
-
Good day fellow CodeProject.com'ers, I have an ASP.NET (C#) Base application which I would like to take the result of a custom user control, and use the resulting HTML from the control (or many multiple controls) as the body in an email. Any ideas?
J - Artificial intelligence is no match for natural stupidity
-
Good day fellow CodeProject.com'ers, I have an ASP.NET (C#) Base application which I would like to take the result of a custom user control, and use the resulting HTML from the control (or many multiple controls) as the body in an email. Any ideas?
J - Artificial intelligence is no match for natural stupidity
Navaneeth How to use google | Ask smart questions
-
Good day fellow CodeProject.com'ers, I have an ASP.NET (C#) Base application which I would like to take the result of a custom user control, and use the resulting HTML from the control (or many multiple controls) as the body in an email. Any ideas?
J - Artificial intelligence is no match for natural stupidity
After posting this I decided to play a little more, and I think I got it, hope this helps someone... I created a user control in the folder "Controls" called "WebUserControl.ascx". I decided if I could write the control programatically to the page, I could then use that variable later for the email section. Here is the code I came up with... if anyone can better it, please post here:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using System.IO;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder stringBuilder = new StringBuilder();
StringWriter stringWriter;
HtmlTextWriter htmlTextWriter;
stringWriter = new System.IO.StringWriter(stringBuilder);
htmlTextWriter = new HtmlTextWriter(stringWriter);Control c1 = LoadControl("Controls/WebUserControl.ascx"); c1.DataBind(); c1.RenderControl(htmlTextWriter); Response.Write (htmlTextWriter.InnerWriter.ToString()); }
}
J - Artificial intelligence is no match for natural stupidity
-
Navaneeth How to use google | Ask smart questions
Thanks, I saw your post just after I posted my last one, I will check it out...
J - Artificial intelligence is no match for natural stupidity
-
Navaneeth How to use google | Ask smart questions
That's a good link, thank you!
J - Artificial intelligence is no match for natural stupidity