send ascx file's html code as email

Discussion in 'ASP .Net' started by Sabri AKIN, Feb 7, 2005.

  1. Sabri AKIN

    Sabri AKIN Guest

    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 AKIN, Feb 7, 2005
    #1
    1. Advertising

  2. Sabri AKIN

    Karl Seguin Guest

    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
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Sabri AKIN" <> wrote in message
    news:229201c50d13$a7532170$...
    > 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.
     
    Karl Seguin, Feb 7, 2005
    #2
    1. Advertising

  3. Sabri AKIN

    Sabri AKIN Guest

    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.



    >-----Original Message-----
    >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
    >--
    >MY ASP.Net tutorials
    >http://www.openmymind.net/
    >
    >
    >"Sabri AKIN" <> wrote

    in message
    >news:229201c50d13$a7532170$...
    >> 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 AKIN, Feb 7, 2005
    #3
  4. 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

    "Sabri AKIN" <> wrote in message
    news:2c4e01c50d20$670e4470$...
    > 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.
    >
    >
    >
    >>-----Original Message-----
    >>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
    >>--
    >>MY ASP.Net tutorials
    >>http://www.openmymind.net/
    >>
    >>
    >>"Sabri AKIN" <> wrote

    > in message
    >>news:229201c50d13$a7532170$...
    >>> 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.

    >>
    >>
    >>.
    >>
     
    Mark Fitzpatrick, Feb 7, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Quentin
    Replies:
    1
    Views:
    489
    Quentin
    Jul 29, 2003
  2. Jason Shohet
    Replies:
    1
    Views:
    486
    Kevin Spencer
    Nov 10, 2003
  3. Holger (David) Wagner
    Replies:
    2
    Views:
    1,945
    Holger (David) Wagner
    Jul 3, 2004
  4. Sabri AKIN

    send ascx file's html code as email

    Sabri AKIN, Feb 7, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    126
    vMike
    Feb 7, 2005
  5. Replies:
    13
    Views:
    498
    Randy Webb
    May 14, 2006
Loading...

Share This Page