Answered by:
Control 'chksameAddr' of type 'CheckBox' must be placed inside a form tag with runat=server.

Question
-
User1216627406 posted
Greetings exports,
I am trying to use itextsharp to export HTML to PDF.
The markup clearly has a <FORM>...</FORM> tag.
However, when I clicked the Export button, I get the following error.
Control 'chksameAddr' of type 'CheckBox' must be placed inside a form tag with runat=server.
The chksameAddr checkbox has a runat="server" attribute as well, so does the Form tag.
I think (but not sure) that the issue is that even though the chksameAddr checkbox control is inside FORM that, because we are trying to export data that is with pnlContents Panel control, itextsharp code no longer recognizes the presence of a FORM tag.
Any ideas how to work around this issue?
Can I have more than one FORM tag in an asp.net MARKUP?
Thanks in advance.
<asp:Panel id="pnlContents" runat = "server"> <div> <table border="1" style="width:100%; text-align:left"> <tr> <td style="width:30%;vertical-align: text-top;font-weight:normal;text-align:center;color:gainsboro">FOR OFFICE ONLY</td> <td style="width:70%;"><div class="auto-style7"><span style="font-weight:bold;color:#4b4b4b;">PERSONAL PROPERTY TAX RETURN</span><br /> <span style="color:#4b4b4b;">This Return will be considered Public Information and Open for Public Inspection</span><br /> <span style="color:#4b4b4b;"> Return completed form to address listed below.</span></div></td> </tr> <tr> <td style="vertical-align: text-top;width:45%;"> <table border="1" class="nav-justified"> <tr> <td class="auto-style5">TAX YEAR</td> <td rowspan="2" class="auto-style2"><span style="margin-left:7px;color:#000;">IF ASSISTANCE NEEDED CALL</span><br /> <span style="margin-left:32px;color:#000;">xxx-xxx-xxxx</span></td> <td class="auto-style1">ACCOUNT NUMBER</td> </tr> <tr> <td class="auto-style5"><asp:Label ID="lblTaxYr" style="color: #0093B2;font-weight:bold;" runat="server" /></td> <td class="auto-style1"><div class="input text"> <asp:Label ID="lblAcctNo" disabled="disabled" style="width:155px; color: #0093B2;font-weight:bold;" runat="server"></asp:Label></div></td> </tr> <tr> <td class="auto-style5"><span style="color:red;">DUE DATE</span></td> <td colspan="2" >OWNER'S PHONE NUMBER (LIST)</td> </tr> <tr> <td class="auto-style5"><asp:Label ID="lblDueDate" style="color: #0093B2;font-weight:bold;" runat="server" /></td> <td colspan="2" ><asp:Label ID="lblOwnerPhone" style="color: #0093B2;font-weight:bold;" runat="server" /></td> </tr> </table> <table style="width:70%" cellspacing="0"> <tr> <td style="text-align:center"><br />Taxpayer NAME AND ADDRESS</td> </tr> <tr><td style="border-collapse: collapse;border: 0px solid black;"> </td></tr> <tr> <td> <table border="0" cellspacing="0"> <tr> <td>NAME:</td><td><div class="input text"> <asp:Label ID="lblfName" style="width:459px;color: #0093B2;font-weight:bold;" runat="server"></asp:Label></div></td> </tr> <tr> <td>ADDRESS:</td><td><div class="input text"> <asp:Label ID="lblfAddress" style="width:459px;color: #0093B2;font-weight:bold;" runat="server"></asp:Label></div></td> </tr> </table> <table border="0"> <tr> <td><span style="margin-left:2px;color:#000;">CITY:</span> </td><td><asp:Label ID="lblfCity" style="width:150px; color: #0093B2;font-weight:bold;" runat="server"></asp:Label>></td><td> STATE:</td><td><div class="input select"> <asp:Label ID="lblfStates" CssClass="Label" disabled="disabled" runat="server"> </asp:Label> </div></td><td> ZIP:</td><td><div class="input text"> <asp:Label ID="lblfZip" style="width:57px; color: #0093B2;font-weight:bold;" runat="server"></asp:Label></div></td> </tr> </table> </td> </tr> <tr><td style="border-collapse: collapse;border: 0px solid black;"> </td></tr><tr><td style="border-collapse: collapse;border: 0px solid black;"> </td></tr> <tr> <td style="border-collapse: collapse;border-top: 1px solid black;border-bottom: 1px solid black;width:100%;"><span style="color:red">The last day for filing this application to receive full exemption</span><br /> <span style="color:red"> is listed in the DUE DATE column above.</span><br /> Note: Most counties do not accept metered mail dates as filing date unless counter<br /> stamped by the post office. Be sure that the date of deposit and the postmark date are the same if mailing is close to the deadline.<br /></td> </tr> </table> </td> <td style="vertical-align: text-top;width:55%;" cellspacing="0"> <table border="0" style="width:100%" cellspacing="0"> <tr> <td style="border-collapse: collapse;border-bottom: 1px solid black;"><div class="auto-style7">NAME AND RETURN ADDRESS</div></td> </tr> <tr> <td style="border-collapse: collapse;border: 1px solid black;">TAX SITUS (WHERE YOU LIVE):</td> </tr> <tr><td> </td></tr> <tr> <td> <asp:Label ID="lblsitus" runat="server" style="width:90%;height:70px;width:257px;color: #0093B2;font-weight:bold;" disabled="disabled"> </asp:Label> <div id="divcitylistprev" style="margin-top:-20px;margin-left:110px;"><asp:Label ID="lblcitylist" class="form-control" style="width:400px; color: #0093B2;font-weight:bold;" placeholder="(Choose...)" runat="server" /></div> </td> </tr> <tr> <td style="border-collapse: collapse;border: 1px solid black;"><span style="margin: auto;width: 86%;padding: 10px;"><asp:CheckBox ID="chksameAddr" style="color: #0093B2;font-weight:bold;" runat="server" />CHECK BOX IF MAILING ADDRESS OR NAME IS SAME</span><br /> <span style="margin: auto;width: 86%;padding: 10px;">OTHERWISE, PLEASE CORRECT IN SPACE PROVIDED BELOW</span></td> </tr> </table> <table border="0" cellspacing="0"> <tr> <td>NAME:</td><td style="border-collapse: collapse;border: 1px solid black;"><div class="input text"> <asp:Label ID="lblfullName" style=" color: #0093B2;font-weight:bold;width:600px;" runat="server"></asp:Label></div></td> </tr> <tr> <td>ADDRESS:</td><td style="border-collapse: collapse;border: 1px solid black;"><div class="input text"> <asp:Label ID="lblAddress" style="width:600px; color: #0093B2;font-weight:bold;" runat="server"></asp:Label></div></td> </tr> </table> <table border="0"> <tr> <td>CITY:<span style="margin-left:32px;color:#000;"></span></td><td style="border-collapse: collapse;border: 1px solid black;"><div class="input text"> <asp:Label ID="lblCity" style="color: #0093B2;font-weight:bold;width:100px;" runat="server"></asp:Label></div></td><td><span style="margin-left:7px;color:#000;">STATE:</span></td><td style="border-collapse: collapse;border: 1px solid black;"><div class="input select"> <asp:Label ID="lblStates" CssClass="Label" disabled="disabled" runat="server" style="width:150px;"> </asp:Label> </div></td><td><span style="margin-left:30px;color:#000;">ZIP:</span></td><td style="border-collapse: collapse;border: 1px solid black;"><div class="input text"> <asp:Label ID="lblZip" style="color: #0093B2;font-weight:bold;width:100px;" runat="server"></asp:Label></div></td> </tr> </table> </td> </tr> </table> <table border="1" style="width:100%;text-align:center;" cellspacing="0"> <tr> <td style="width:100%;vertical-align: text-top;"> <table rules="all" border="1" width="100%" style="border-collapse:collapse;table-layout: fixed;"> <tr> <th align="left" scope="col">B - BOATS AND MOTORS - INCLUDE ALL CRAFT IN AND ABOVE<br /> THE WATER, THE MOTORS BUT NOT THE LAND TRANSPORT VEHICLES (TRAILERS).</th> <th scope="col">TaxPayer Returned Value <br />As of Jan This Year</th> <th scope="col"><span style="color:gainsboro;margin-left:50px;">For Tax Office use Only</span> <br /><span style="color:gainsboro;margin-left:50px;"> (Tax Assessirs Value)</span></th> </tr> <%foreach (System.Data.DataRow row in dtAirInfoTable.Rows) {%> <tr> <td> <span class="form-control" style="width: 493px; color: #0093B2;font-weight: bold"> <%=Convert.ToString(row.ItemArray[1].ToString())%></span> </td> <td align="center"> <span class="form-control txtPayerret" style="width: 400px;color: #0093B2; font-weight: bold"><%=Convert.ToString(row.ItemArray[2].ToString())%></span> </td> </tr> <tr> <td> <span class="form-control" style="width: 493px; color: #0093B2;font-weight: bold"> $<%=Convert.ToString(row.ItemArray[3].ToString())%></span> </td> <td align="center"> <span class="form-control txtPayerret" style="width: 400px;color: #0093B2; font-weight: bold">$<%=Convert.ToString(row.ItemArray[4].ToString())%></span> </td> </tr> <% } %> </table> </td> </tr> <tr> <td> <table rules="all" border="1" width="100%" style="border-collapse:collapse;table-layout: fixed;" cellspacing="0"> <tr> <td>TOTAL<span style="margin-left:200px;color:#000000;font-weight:bold;">></span></td> <td> <span style="margin-left:131px;">$<asp:Label ID="lblTotalPrev" style="color: #0093B2;font-weight: bold;width: 326px;" runat="server"></asp:Label></span></td> <td></td> </tr> </table> </td> </tr> </table> <asp:Repeater ID="rptpreview" runat="server"> <ItemTemplate> <table style="width: 100%;" border="1" class="myForm" cellspacing="0"> <tr> <td style="white-space: nowrap;" colspan="2"> WHERE BOAT IS FUNCTIONALLY LOCATED): WHERE:<asp:Label ID="aircraftcntyPreview" Text='<%#Eval("boatcnty") %>' Style="width: 150px;" runat="server"></asp:Label> </td> <tr> <td>Registration "N" #:<asp:Label ID="aRegNoPreview" runat="server" Style="width: 270px; margin-left: 195px;color: #0093B2;" Text='<%#Eval("aRegNo")%>'></asp:Label> </td> <td></td> </tr> <tr> <td style="white-space: nowrap;">MFG. Name: (make):<asp:Label ID="aMakePreview" runat="server" Text='<%#Eval("aMake") %>' Style="width: 270px; margin-left: 175px;color: #0093B2;"></asp:Label> </td> <td style="white-space: nowrap;">MFG. Name: (make):<asp:Label ID="mMakePreview" runat="server" Text='<%#Eval("mMake") %>' Style="width: 270px; margin-left: 175px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td style="white-space: nowrap;">Model Name OR #::<asp:Label ID="aModelNoPreview" runat="server" Text='<%#Eval("ModelNoA") %>' Style="width: 270px; margin-left: 184px;color: #0093B2;"></asp:Label> </td> <td>Model Name OR #::<asp:Label ID="mModelNoPreview" runat="server" Text='<%#Eval("ModelNoM") %>' Style="width: 270px; margin-left: 184px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td style="white-space: nowrap;">Year Built:<asp:Label ID="boatYrBuiltPreview" runat="server" Text='<%#Eval("boatYrBuilt") %>' Style="width: 270px; margin-left: 250px;color: #0093B2;"></asp:Label> </td> <td>Year Built:<asp:Label ID="motorYrBuiltPreview" runat="server" Text='<%#Eval("motorYrBuilt") %>' Style="width: 270px; margin-left: 250px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td style="white-space: nowrap;">Length:<asp:Label ID="blengthPreview" runat="server" Text='<%#Eval("blength") %>' Style="width: 130px; margin-left: 26px;color: #0093B2;"></asp:Label> <span style="margin-left:122px;">Hull Material:<asp:Label ID="hullmaterial" runat="server" Text='<%#Eval("hullmaterial") %>' Style="width: 140px; margin-left: 26px;color: #0093B2;"></asp:Label> </span></td> <td>HorsePower:<asp:Label ID="mhorsepowerPreview" runat="server" Text='<%#Eval("mhorsepower") %>' Style="width: 130px; margin-left: 231px;color: #0093B2;"></asp:Label> <asp:Label ID="mhorsepTypePreview" runat="server" Text='<%#Eval("rdlmhorsepType") %>' style="display:inline;color: #0093B2;" TextAlign="Right"> </asp:Label> <br /> </td> </tr> <tr> <td style="white-space: nowrap;">Date Purchased:<asp:Label ID="datePurchasedvPreview" runat="server" Text='<%#Eval("datePurchased") %>' Style="width: 270px; margin-left: 205px;color: #0093B2;"></asp:Label> </td> <td>Date Purchased:<asp:Label ID="mdatePurchasedPreview" runat="server" Text='<%#Eval("mdatePurchased") %>' Style="width: 270px; margin-left: 205px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td>Purchased:<asp:Label ID="rblPurchaseTypePreview" runat="server" Text='<%#Eval("PurchaseType") %>' style="display:inline;margin-left: 245px;color: #0093B2;" TextAlign="Right"> </asp:Label> <br /> </td> <td>Purchased:<asp:Label ID="rblmPurchasedTypePreview" runat="server" AutoPostBack="true" RepeatDirection="Horizontal" Text='<%#Eval("rblmPurchasedType") %>' style="display:inline;margin-left: 245px;color: #0093B2;" TextAlign="Right" ValidationGroup="stype"> </asp:Label> <br /> </td> </tr> <tr> <td> <span style="text-align:left;">If purchased used this year, write the name and address of the previous owner.</span> <br /> <div class="input text select"> NAME: <asp:Label ID="PrevOnwerNamePreview" runat="server" Text='<%#Eval("PrevOnwerName") %>' style="width:200px;color: #0093B2;"></asp:Label> ADDRESS: <asp:Label ID="txtprevAddrPreview" runat="server" Text='<%#Eval("prevAddr") %>' style="width:200px;color: #0093B2;"></asp:Label> <span style="white-space:nowrap;">CITY:<asp:Label ID="prevCityPreview" runat="server" Text='<%#Eval("prevCity") %>' style="width:100px; margin-left:15px;color: #0093B2;"></asp:Label> STATE: <asp:Label ID="ddlPrevStatePreview" runat="server" Text='<%#Eval("PrevState") %>' cssClass="disabledcss" style="color: #0093B2;"> </asp:Label> ZIP:<asp:Label ID="prevzipPreview" Text='<%#Eval("prevzip") %>' runat="server" style="color: #0093B2;"></asp:Label> </span> </div> </td> <td> <asp:Panel ID="Panel1" runat="server" Enabled="false"> <span style="text-align:left;">If purchased used this year, write the name and address of the previous owner.</span> <br /> <div class="input text select"> NAME: <asp:Label ID="mPrevOnwerNamePreview" runat="server" Text='<%#Eval("mprevOnwerName") %>' style="width:200px;color: #0093B2;"></asp:Label> ADDRESS: <asp:Label ID="mprevAddrPreview" runat="server" Text='<%#Eval("mprevAddr") %>' style="width:200px;color: #0093B2;"></asp:Label> <span style="white-space:nowrap;">CITY:<asp:Label ID="mprevCityPreview" runat="server" Text='<%#Eval("mprevCity") %>' style="width:100px; margin-left:15px;color: #0093B2;"></asp:Label> STATE: <asp:Label ID="mPrevStatePreview" runat="server" Text='<%#Eval("mPrevState") %>' cssClass="disabledcss" style="color: #0093B2;"></asp:Label> ZIP:<asp:Label ID="mprevzipPreview" runat="server" style="color: #0093B2;" Text='<%#Eval("mprevzip") %>'></asp:Label> </span> </div> </asp:Panel> </td> </tr> <tr> <td style="border-collapse: collapse;">If you sold or traded your boat and did not own on January 1 this year, provide details of the new buyer below in order for the items to be removed from your account.<br /> <div class="input text select"> NAME:<asp:Label ID="buyernamePreview" runat="server" Text='<%#Eval("buyername") %>' style="width:200px;color: #0093B2;"></asp:Label> ADDRESS:<asp:Label ID="buyeraddressPreview" runat="server" Text='<%#Eval("buyeraddress") %>' style="width:200px;color: #0093B2;"></asp:Label> <br /> <span style="margin-left:32px;color:#000;">CITY:<asp:Label ID="buyercityPreview" runat="server" Text='<%#Eval("buyercity") %>' style="width:150px;color: #0093B2;"></asp:Label> </span>STATE: <asp:Label ID="buyerstatePreview" runat="server" Text='<%#Eval("buyerstate") %>' style="color: #0093B2;"> </asp:Label> ZIP:<asp:Label ID="buyerzipPreview" runat="server" Text='<%#Eval("buyerzip") %>' style="width:50px;color: #0093B2;"></asp:Label> </div> <div class="input text"> Date Sold:<asp:Label ID="datesoldPreview" runat="server" Text='<%#Eval("datesold") %>' style="color: #0093B2;"></asp:Label> <span style="margin-left:220px;color:#333;">Sale Price:<asp:Label ID="bsalePricePreview" runat="server" Text='<%#Eval("salePrice") %>' style="color: #0093B2;"></asp:Label> </span> </div> <br /> <div class="input textarea"> Description:<asp:Label ID="DescriptionPreview" runat="server" Text='<%#Eval("Description") %>' style="width:350px; color: #0093B2;" TextMode="MultiLine"></asp:Label> </div> </td> <td style="border-collapse: collapse;">If you sold or traded your motor and did not own on January 1 this year, provide details of the new buyer below in order for the items to be removed from your account.<br /> <div class="input text select"> NAME:<asp:Label ID="mbuyernamePreview" runat="server" Text='<%#Eval("mbuyername") %>' style="width:200px; color: #0093B2; color: #0093B2;"></asp:Label> ADDRESS:<asp:Label ID="mbuyeraddressPreview" runat="server" Text='<%#Eval("mbuyeraddress") %>' style="width:200px; color: #0093B2;"></asp:Label> <br /> <span style="margin-left:32px;color:#000;">CITY:<asp:Label ID="mbuyercityPreview" runat="server" Text='<%#Eval("mbuyercity") %>' style="width:150px; color: #0093B2;"></asp:Label> STATE: <asp:Label ID="mbuyerstatePreview" runat="server" Text='<%#Eval("mbuyerstate") %>' style="color: #0093B2;"> </asp:Label> ZIP:<asp:Label ID="mbuyerzipPreview" runat="server" Text='<%#Eval("mbuyerzip") %>' style="width:50px; color: #0093B2;"></asp:Label> </span> </div> <br /> <div class="input text"> Date Sold:<asp:Label ID="mdatesoldPreview" runat="server" Text='<%#Eval("mdatesold") %>' style="color: #0093B2;"></asp:Label> <span style="margin-left:220px;color:#333;color: #0093B2;">Sale Price:<asp:Label ID="msalePricePreview" runat="server" Text='<%#Eval("msalePrice") %>'></asp:Label> </span> </div> <br /> <div class="input textarea"> Description:<asp:Label ID="mDescriptionPreview" runat="server" Text='<%#Eval("mDescription") %>' style="width:350px;color: #0093B2;" TextMode="MultiLine"></asp:Label> </div> </td> </tr> <tr> <td style="white-space:nowrap;">Cost:<asp:Label ID="boatCostPreview" runat="server" Text='<%#Eval("boatCost") %>' style="width:270px;margin-left:50px;color: #0093B2;"></asp:Label> </td> <td>Cost:<asp:Label ID="motorCostPreview" runat="server" Text='<%#Eval("motorCost") %>' style="width:270px;margin-left:50px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td align="center"> Is there anything functionally wrong with your boat?<br /> <asp:Label ID="rblIssuesPreview" runat="server" Text='<%#Eval("rblIssues") %>' style="display:inline;color: #0093B2;" TextAlign="Right"></asp:Label> <br /> If yes please provide the Board of Assessors with documentation<br /> in order for them to make a proper assessment.<br /> <br /> List anything functionally wrong with your boat: <div class="input textarea"> <asp:Label ID="functionalIssesPreview" runat="server" Text='<%#Eval("functionalIsses") %>' style="width:400px;color: #0093B2;" TextMode="MultiLine"></asp:Label> </div> </td> <td align="center"> Is there anything functionally wrong with your motor?<br /> <asp:Label ID="mrblIssuesPreview" runat="server" Text='<%#Eval("mrblIssues") %>' style="display:inline;color: #0093B2;" TextAlign="Right"></asp:Label> <br /> If yes please provide the Board of Assessors with documentation<br /> in order for them to make a proper assessment.<br /> <br /> List anything functionally wrong with your boat: <div class="input textarea"> <asp:Label ID="mfunctionalIssesPreview" runat="server" Text='<%#Eval("mfunctionalIsses") %>' style="width:400px;color: #0093B2;" TextMode="MultiLine"></asp:Label> </div> </td> </tr> <tr> <td colspan="2">FEDERAL DOCUMENTED VESSEL </td> </tr> <tr> <td colspan="2">Type and Use of Vessel:<asp:Label ID="vesseltypeUsePreview" runat="server" Text='<%#Eval("vesseltypeUse") %>' style="width:800px;margin-left:50px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td colspan="2" style="white-space:nowrap;">Vessel Name:<asp:Label ID="vesselnamePreview" runat="server" Text='<%#Eval("vesselname") %>' style="width:200px;margin-left:125px;color: #0093B2;"></asp:Label> <span style="margin-left:30px;"></span>Length:<asp:Label ID="vessellengthPreview" runat="server" Text='<%#Eval("vessellength") %>' style="width:200px;margin-left:10px;"></asp:Label> <span style="margin-left:30px;color:#000;font-weight:bold;">Year Built:<asp:Label ID="vesselYrBultPreview" runat="server" Text='<%#Eval("vesselYrBult") %>' style="width:200px;margin-left:10px;color: #0093B2;"></asp:Label> </span><span style="margin-left:30px;color:#000;font-weight:bold;">Hull Material:<asp:Label ID="VeseelHullMateriaPreview" runat="server" Text='<%#Eval("VesselHullMateria") %>' style="width:200px;margin-left:10px;color: #0093B2;"></asp:Label> </span></td> </tr> <tr> <td colspan="2" style="white-space:nowrap;">HorsePower and Type of Engine:<asp:Label ID="vesselhorsepEnginePreview" runat="server" Text='<%#Eval("vesselhorsepEngine") %>' style="width:500px;margin-left:125px;color: #0093B2;"></asp:Label> <span style="margin-left:135px;"></span>Coast Guard Number:<asp:Label ID="vesselCGuardNumPreview" runat="server" style="width:200px;margin-left:10px;color: #0093B2;" Text='<%#Eval("coastGuardNumber")%>'></asp:Label> </td> </tr> <tr> <td colspan="2" style="white-space:nowrap;">Year Purchased:<asp:Label ID="VesselYrPurchasedPreview" runat="server" Text='<%#Eval("VesselYrPurchased") %>' style="width:200px;margin-left:241px;color:#000;font-weight:bold;color: #0093B2;"></asp:Label> <span style="margin-left:30px;color:#000;font-weight:bold;">Purchased New?:</span> <span style="margin-left:60px;color:#000;font-weight:bold;color: #0093B2;"> <asp:Label ID="VPurchasedNewPreview" runat="server" Text='<%#Eval("PurchasedNew") %>' style="display:inline;color: #0093B2;" TextAlign="Right"> </asp:Label> </span><span style="margin-left:30px;color:#000;font-weight:bold;">Amount of Purchase:<asp:Label ID="VesselPurchaseAmtPreview" runat="server" Text='<%#Eval("VesselPurchaseAmt") %>' style="width:200px;margin-left:18px;color:#6E6E6E;"></asp:Label> </span></td> </tr> <tr> <td colspan="2" style="white-space:nowrap;">Home Port:<asp:Label ID="homePortPreview" runat="server" Text='<%#Eval("homePort") %>' style="width:350px;margin-left:125px;color: #0093B2;"></asp:Label> <span style="margin-left:313px;"></span>Where Docked:<asp:Label ID="whereDockedPreview" runat="server" Text='<%#Eval("whereDocked") %>' style="width:350px;margin-left:38px;color: #0093B2;"></asp:Label> </td> </tr> <tr> <td colspan="2" style="margin-left:313px;">Boat and Motor Equipment Accessory List:<br /><asp:Label ID="bmequipAccessoryListPreview" runat="server" Text='<%#Eval("bmequipAccessoryList") %>' style="width:700px;color: #0093B2;" TextMode="MultiLine"></asp:Label> </td> </tr> </table> </ItemTemplate> </asp:Repeater> <br /><br /> <table border="1" style="width: 100%; text-align: left" cellspacing="0"> <tr> <td style="width: 20%"> <div> <asp:CheckBox ID="lblchkTerms" runat="server" /> I do: <span id="lblTermsRequired" style="display: none; color: red;"><span style="color: red;"> Check the box before you can submit your data</span></span> </div> </td> <td style="width: 20%"> Title: <asp:Label ID="lblTitle" runat="server" Style="color: #0093B2;"></asp:Label> </td> <td style="width:20%;">Email:<asp:Label id="lblEmail" runat="server" Style="color: #0093B2;"></asp:Label></td> <td style="width:20%">Preparer Signature: <asp:Label id="lblpreparerName" runat="server" Style="color: #0093B2;"></asp:Label></td> <td style="width: 20%"> Date: <asp:Label ID="lblSignDate" runat="server"></asp:Label> </td> </tr> </table> </div> </asp:Panel>
Tuesday, April 17, 2018 3:49 PM
Answers
-
User1216627406 posted
Since I wasn't sold on the suggestions here, I googled and found a very simple solution that worked for me.
I added this:
public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ }
and it worked like a charm.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, April 19, 2018 5:06 PM
All replies
-
User-1838255255 posted
Hi simflex,
According to your description and except message, could you tell us which line code caused this issue?
if you add some controls or other in the code behind? Here are someone who meet the similar issue as you, please check:
Control '0' of type 'TextBox' must be placed inside a form tag with runat=server:
Must be Placed Inside a Form Tag With runat=server:
https://stackoverflow.com/questions/21553885/must-be-placed-inside-a-form-tag-with-runat-server
Best Regards,
Eric Du
Wednesday, April 18, 2018 6:28 AM -
User1216627406 posted
Thank you Eric.
My apologies for the long code.
This is the sub:
protected void btnExport_Click(object sender, EventArgs e) { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); pnlContents.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
And the offending line of code is this:
pnlContents.RenderControl(hw);
Because we are only interested in exporting contents within the Panel control, somehow, the C# code got confused, I think, thinking there is no FORM tag associated with it.
Your first reference is a very good resource.
According to that solution, the form ID needed to be reference on codebehind.
So, since my form ID is msform, I tried referencing it like this:
msform.pnlContents.RenderControl(hw);
However, it get an error:
'HtmlForm' does not contain a definition for 'pnlContents' and no extension method 'pnlContents' accepting a first argument of type 'HtmlForm' could be found (are you missing a using directive or an assembly reference?)
Any other way of referencing the form ID?
Wednesday, April 18, 2018 1:31 PM -
User475983607 posted
The error describes exactly the issue. The code is trying to render a section of the Web Form and that section does not have a Form server control.
You'll need to rethink the design. A few ideas...
- Create a web form dynamically, adding the panel to the dynamically created form, then rendering the form.
- Create a separate Web Form that has the content and layout that you're wanting. Invoke this new Web Form when the btnExport is clicked.
IMHO, a new web form is cleaner and easier to control but probably more work.
Wednesday, April 18, 2018 1:52 PM -
User1216627406 posted
Since I wasn't sold on the suggestions here, I googled and found a very simple solution that worked for me.
I added this:
public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ }
and it worked like a charm.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, April 19, 2018 5:06 PM