send ascx file's html code as email

  • Thread starter Thread starter Sabri AKIN
  • Start date Start date
S

Sabri AKIN

Hi,
I want to send ascx file's html code as email.this ascx
file is summary of customer sale.and at last iwant to
send email to customer.how can i get and past ascx file's
html code to mail body.
 
Sabri:
You can do something like this:

Control c = Page.LoadControl("x.ascx");
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw) ;
string contents = null;
try{
c.RenderControl(writer);
contents = sw.GetStringBuilder().ToString();
}finally{
sw.Close();
writer.Close();
}

Karl
 
thanks,
its work fine but i have to pass parameter to ascx file
like orderID.
how can i pass parameter to this webcontrol page with
this code.
 
Instead of passing parameters, use properties, that way you can set the
properties after you use the LoadControl method. You'll have to create a
reference as the actual type though instead of the base Control class in
order to set the properties correctly.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
Back
Top