send ascx file's html code as email

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.
 
K

Karl Seguin

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
 
S

Sabri AKIN

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.
 
M

Mark Fitzpatrick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top