网页导出为pdf/word [英] webpage export to pdf/word

查看:74
本文介绍了网页导出为pdf/word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友


我尝试将网页(具有Gridview和其他服务器端控件)导出为PDF
当时我遇到类似
的错误 必须将类型为"GridView"的控件"GridView1"放置在带有runat = server的表单标记中."

请帮助我解决此错误

hi friends


i try to export the webpage(have Gridview and other server side control) to PDF
at that time i got the error like
" Control ''GridView1'' of type ''GridView'' must be placed inside a form tag with runat=server. "

please help me resolve this Error

<br />
<form id="form1"  runat="server"><br />
    <div id ="Pdf"  runat="server" ><br />
        <div><br />
            <h1><br />
                abc desc<br />
            </h1><br />
        </div><br />
        <div><br />
             <br /><br />
            VB.NET samples for ASP.NET and Windows Forms in the downloaded archive. The<br />
            converter fully supports HTML tags and CSS, including page breaks control with CSS<br />
            styles. Adding HTML in the headers and footers is also supported. No printer driver<br />
            insta<asp:GridView ID="GridView1" runat="server"><br />
            <br />
            llation or additional settings are necessary in order to get it working. We<br />
            offer full C# and VB.NET samples for ASP.NET and Windows Forms in the downloaded<br />
            archive.<br />
            <asp:Label ID="Label1" runat="server" Text="Label"> <br />
            <asp:Label ID="lblmessage" runat="server"><br />
        </div><br />
        <br />
        <div><br />
            <asp:Button ID="btnExport" runat="server" Text="Button" />   <br />
             <br />
        </div><br />
    </form><br />



-------------------------------------------------- ---------------------------
在btnExport.click事件中调用此函数(getData())



-----------------------------------------------------------------------------
call this function (getData()) at btnExport.click Events

<br />
    Protected Sub getData()<br />
        Try<br />
            Response.Clear()<br />
            Response.Buffer = True<br />
            Response.AddHeader("content-disposition", "attachment;filename=FileName.doc")<br />
            Response.ContentEncoding = System.Text.Encoding.UTF7<br />
            Response.ContentType = "application/test.word"<br />
            Dim oStringWriter As New System.IO.StringWriter()<br />
            Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)<br />
            Pdf.RenderControl(oHtmlTextWriter)<br />
            Response.Output.Write(oStringWriter.ToString())<br />
            Response.Flush()<br />
            Response.End()<br />
        Catch ex As Exception<br />
            MsgBox(ex.Message.ToString)<br />
        End Try<br />
    End Sub<br />
<br />




谢谢提前


karthikIc




thanks advance


karthikIc

推荐答案

错误本身显示
"GridView1"必须放置在带有runat = server的表单标签中.
你尝试过吗?
:doh:我没注意到.
您有< asp:GridView ID ="GridView1" runat ="server">没有结束标签
Error itself says
''GridView1'' must be placed inside a form tag with runat=server.
Did you try that?
:doh: I didn''t notice.
You have <asp:GridView ID="GridView1" runat="server"> without closing tag


这篇关于网页导出为pdf/word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆