c#rendercontrol到一个html文件

时间:2015-11-06 16:10:30

标签: c# webforms user-controls asp.net-2.0

我正在尝试将asp.net面板控件渲染为html文件。以下是与此相关的代码部分。

public void CreateHTMLFile(string outHTMLFile)
{
    System.IO.StringWriter sw = new System.IO.StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    _reportPanel.RenderControl(hw);

enter image description here

更新

protected void downloadPDFLinkButton_Click(object sender, EventArgs e)
    {
        datesLiteral.Text = startDate.Text + " to " + endDate.Text;
        schoolID = Convert.ToInt32(schoolDropDownList.SelectedValue);
        BuildIntro();
        BuildCoachingReportTableMain();
        BuildMinutesTable();
        BuildContentAreasTable();
        BuildFrameworkTable();
        BuildTeacherMinutes();
        reportPanel.Visible = true;
        selectionPanel.Visible = false;
        selectionLinkButton.Visible = false;
        PDFLinkButton.Visible = false;
        string reportTitle = "<h1>" + "" + "</h1>";
        PDFConversion pc = new PDFConversion();
        pc.Convert(PDFPanel, reportTitle, false, "open");
        selectionLinkButton.Visible = true;
        PDFLinkButton.Visible = true;

    }

public void Convert(System.Web.UI.WebControls.Panel reportPanel, string reportTitle,
                    bool fontSmall, string action)
{
    PanelToHTMLForPDF panelHP = new PanelToHTMLForPDF(reportPanel, reportTitle, fontSmall);
    _isNetPanelToPDF = true;
    Convert(panelHP, action);
}

public PanelToHTMLForPDF(System.Web.UI.WebControls.Panel reportPanel, string     reportTitle,
                    bool fontSmall)
{
    _reportPanel = reportPanel;
    _reportTitle = reportTitle;
    _fontSmall = fontSmall;
}

更新

我测试了它看起来不是导致错误的asp.net文字。

0 个答案:

没有答案