System.Web.HttpException:类型为'TextBox'的'Control'txtSearchFirstAider'必须放置在带有runat = server的表单标记中。'
我收到此错误,并且确保将其放置在标签中,并且没有使用任何母版页。谁能帮忙。
这是我的后端代码。利用VB.Net
Protected Sub btnExportPDF_Click(sender As Object, e As EventArgs)
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
pnlAllFirstAiders.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.End()
End Sub
这是我的前端代码
<form runat="server">
<div class="col-6">
<asp:TextBox ID="txtSearchFirstAider" placeholder="search employee clock no . . . . ." ReadOnly="false" CssClass="form-control mb-2 mr-sm-2" TextMode="Search" runat="server"></asp:TextBox>
<asp:Label ID="lblSearchFirstAiderResult" Visible="false" CssClass="text-danger btn-block" runat="server" Font-Bold="true" Text="no results found !"></asp:Label>
</div>
</form>
答案 0 :(得分:0)
谢谢大家的帮助,我已经设法解决了最初的问题。