locked
Panel to CSV to Email RRS feed

  • Question

  • User1980526530 posted

    Hey guys,

    I am running into an issue. Basically what I am trying to do is to create an invoice and send it via email.

    So I am using Ajax CalendarExtender and I do have the Toolscrkipt manager registered at the top of my page and I am using .net 4 with VS 2010.

    So after a few failure I decided to export the asp:panel containing the Invoice to a CSV and then send the CSV to email. I google a few stuff and found a few codes, so this is my code for now when I hit create invoice button:

     Dim SB As New StringBuilder()
            Dim SW As New StringWriter(SB)
            Dim htmlTW As New HtmlTextWriter(SW)
            pnCreateInvoice.RenderControl(htmlTW)
            Dim strOut As String = htmlTW.ToString
    
            Dim strCSV As String
            strCSV = tbInvoiceNumber.Text & "_" & tbClientName.Text
            For Each c In System.IO.Path.GetInvalidPathChars
                strCSV = strCSV.Replace("c", "")
            Next
            strCSV = strCSV.Replace("/", "-")
    
            Dim TargetFile As StreamWriter
    
            Try
                TargetFile = New StreamWriter("~/invoices/" & strCSV & ".csv", True)
                TargetFile.Write(htmlTW)
                TargetFile.WriteLine()
                TargetFile.Write(strOut)
                TargetFile.Close()
                lblCreateInvoiceError.Text = "Completed"
            Catch ex As Exception
                lblCreateInvoiceError.Text = ex.Message.ToString
            End Try

    This is the error I get when I hit the button:

    Extender control 'tbInvoiceDateCalendarExtender' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). Parameter name: extenderControl              Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.            
    Exception Details: System.ArgumentException: Extender control 'tbInvoiceDateCalendarExtender' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). Parameter name: extenderControl
    Source Error:

    Line 364:        Dim SW As New StringWriter(SB)
    Line 365:        Dim htmlTW As New HtmlTextWriter(SW)
    Line 366:        pnCreateInvoice.RenderControl(htmlTW)
    Line 367:        Dim strOut As String = htmlTW.ToString
    Thursday, January 9, 2014 7:58 PM

Answers

  • User1980526530 posted

    I found a way around it instead of trying to save it to CSV or XML there is something I am doing wrong and with all the googeling I  did for 2 days and this forums I just decided to send the invoice via email to the customer lol. Problems solve. but thanks for all the answers.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 15, 2014 11:10 AM

All replies