A page can have only one server-side Form tag. error

127 Views Asked by At

enter image description here

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="ESign_License.aspx.cs" Inherits="ESign_License" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>       
</head>
<body>
<form id="license" runat="server">       
        <asp:Image ID="logo" runat="server" ImageAlign="Middle" Width="100px" Height="100px" CssClass="img" /><br />       
    <table style="width: 100%; height: 800px">
        <tr>                
            <td colspan="2" align="center">
                <asp:Image ID="logo" Width="100px" Height="100px" runat="server" ImageUrl="~/Image/kar_logo4.jpg" ImageAlign="Middle" />
            </td>

        </tr>
        <tr style="height:10px!important;">
            <%-- <td class="auto-style2"></td>--%>
            <td colspan="2" align="center">
                <span style="font-size: 25px">License</span>
            </td>
        </tr>
        <tr style="height:10px!important;">
            <td class="auto-style2"></td>
            <td style="border: 0px; margin: auto;  width: 40%; text-align: left">
                <br />

                  Registration No -
                        <asp:Label ID="Reg_no" runat="server"></asp:Label>
                <br />
                License No -
                        <asp:Label ID="lbllice_no" runat="server"></asp:Label><br />
                Valid From -
                        <asp:Label ID="isueDate" runat="server"></asp:Label><br />
                Valid upto -
                        <asp:Label ID="validDate" runat="server"></asp:Label>

            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <b>FORM 'A2' </b>
                <br />
                ACKNOWLEDGEMENT<br />
                (<asp:Label ID="License_type" runat="server" Text="Label"></asp:Label>
                )<br />
                [See Clause 8 (3)]<br />
            </td>
        </tr>
    </table>
    <br />
    <div class="row">
        <div class="col-md-12">
            <table class="table">
                <tr>
                    <td colspan="2" style="padding-top: 0px; height: 30%">
                        <p>
                            Received from
                                           <asp:Label ID="lblmrs" runat="server"></asp:Label>
                            &nbsp;<asp:Label ID="lblname" runat="server"></asp:Label>
                            ,
                                        <asp:Label ID="lblpname" runat="server" Text="Label"></asp:Label>
                            , a complete Memorandum of Intimation along with Form O, fee of Rs.
                                                <asp:Label ID="lblfee" runat="server"></asp:Label>
                            /- bearing SBI(Govt.),
                                                <asp:Label ID="lblbranch" runat="server"></asp:Label>
                            , Dated
                                                <asp:Label ID="lblpaiddate" runat="server"></asp:Label>
                            .
                                                <br />
                        </p>
                        <br />
                        <p>This acknowledgement shall be deemed to be the letter of authorization entitling the applicant to carry on the business as applied for, for a period of 5 years from the date of issue of this Memo of acknowledgement unless suspended or revoked by the competent authority.</p>
                        <br />
                        <p>

                                        <asp:Label ID="lblrespon" runat="server"></asp:Label>
                            ,
                                            <asp:Label ID="lblradres" runat="server"></asp:Label>
                            , Email-id:
                                                <asp:Label ID="lblemail" runat="server"></asp:Label>
                            , Mob. No:
                                                <asp:Label ID="lblmob" runat="server"></asp:Label>
                            &nbsp;is the responsible officer as per clause 24 of FCO, 1985.
                        </p>
                        <br />
                        <br />
                        *Enclosed details of Fertilizers in Annexure.
                    </td>
                </tr>

            </table>
     </form>
  </body>
  </html>

   protected void export_click(object sender, EventArgs e)
    {
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter hw = new HtmlTextWriter(sw))
            {
                string strid = Utilities.Decrypt(Request.QueryString["lbid1122"].ToString().Trim().Replace(" ", "+"), ConfigurationManager.AppSettings["AadharEncKey"]);
                string appPath = HttpContext.Current.Request.ApplicationPath;
                logo.ImageUrl = Server.MapPath(".") + "\\Image\\kar_logo4.jpg";                   
                string path = Server.MapPath(appPath + "eSign/eSignfiles/" + strid + ".pdf");
                this.Page.RenderControl(hw);
                dynamic output = new FileStream(path, FileMode.Create);
                StringReader sr = new StringReader(sw.ToString());
                Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, output);
                pdfDoc.Open();                  
                XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);                   
                pdfDoc.Close();
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=" + strid + ".pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
             }
        }
    }

Page shows only one server side form tag error eventhough i have only one form tag i am not using any masterpage also . Please help me what may be the issue in this . I have posted full code of the page please look into this i have not used form tag anywhere in the code .

one thing is Its working completely fine in local but when pushed to server we are getting this error

I am using XMLWorkerHelper to generate PDF is this error because of that ??

UPDATE Page load code

protected void Page_Load(object sender, EventArgs e)
    {       
            pageName = Path.GetFileName(Request.Path);
            uid = Session["UserID"] != null ? Convert.ToString(Session["UserID"].ToString().Trim()) : "";
        if (IsPostBack == false)
        {
            if ((Session["RoleCode"].ToString() == "11") || (Session["RoleCode"].ToString() == "2") || (Session["RoleCode"].ToString() == "5") || (Session["RoleCode"].ToString() == "8") || (Session["RoleCode"].ToString() == "4"))
            {
                uploading();
                gridstoragebind();
                export_click(this, null);
            }
            else
            {
                Session.Clear();
                Response.Redirect("~/Login.aspx");
            }
        }

UPDATE Uploading() method

 private void uploading()
   {
    try
    {
        if (con.State == ConnectionState.Closed)
            con.Open();
        string strid = Utilities.Decrypt(Request.QueryString["lbid1122"].ToString().Trim().Replace(" ", "+"), ConfigurationManager.AppSettings["AadharEncKey"]);            

        string query = "select LI.RegNo,af.App_Name,af.Photo,d.DName,t.TName,ur.Gender,af.Sales_Adress,dt.Dealer_Region,LI.License_No,LI.Responsible_person,LI.Generated_Date,LI.Respo_Adres,LI.Respo_adhar,LI.Respo_email,LI.Respo_Mob, convert(varchar(100),LI.Issue_Date,103) Issue_Date,convert(varchar(100),LI.Valid_Date,103) Valid_Date,d.DName,t.TName,LI.Approved_by,FP.AmountPaid,FP.BranchName,convert(varchar(100),FP.PaidDate,103) as PaidDate from FL_License_issued as LI " +
                        "join FL_Form_A1 as af on af.Reg_No=LI.RegNo " +
                        "join User_Registration as ur on af.user_id = ur.user_id " +
                        "join FL_mst_Applying_category as dt on LI.Dealer_Type=dt.Dealer_Code " +
                        "left join FeePayment as FP on LI.RegNo=FP.RegNo " +
                        "left join District as d on LI.ADistrict=d.DCode " +
                        "left join Taluk as t on LI.ADistrict=t.DCode and LI.ATaluk=t.TCode " +
                        "where LI.RegNo='" + strid + "'";

        SqlDataAdapter ad = new SqlDataAdapter(query, con);
        DataTable dt = new DataTable();
        ad.Fill(dt);

        if (dt.Rows.Count > 0)
        {
            Reg_no.Text = dt.Rows[0]["RegNo"].ToString().Trim();
            lbllice_no.Text = dt.Rows[0]["License_No"].ToString().Trim();
            isueDate.Text = dt.Rows[0]["Issue_Date"].ToString().Trim();
            validDate.Text = dt.Rows[0]["Valid_Date"].ToString().Trim();
            License_type.Text = dt.Rows[0]["Dealer_Region"].ToString().Trim();

            lblfee.Text = dt.Rows[0]["AmountPaid"].ToString().Trim();
            lblbranch.Text = dt.Rows[0]["BranchName"].ToString().Trim();
            lblpaiddate.Text = dt.Rows[0]["PaidDate"].ToString().Trim();
            Session["approved_by"] = dt.Rows[0]["Approved_by"].ToString().Trim();

            if (dt.Rows[0]["Photo"].ToString().Trim() != null || dt.Rows[0]["Photo"].ToString().Trim() != "")
            {
                Session["Photo"] = (byte[])dt.Rows[0]["Photo"];
                string encrypt_id = Utilities.encrypt(Utilities.convt("3"), ConfigurationManager.AppSettings["AadharEncKey"]);
                // img_dealer.ImageUrl = "Image.aspx?id=" + encrypt_id + "";
                Session["ImageUrl"] = "Image.aspx?id=" + encrypt_id + "";
            }
            else
            {
                // img_dealer.ImageUrl = null;
            }


            if (dt.Rows[0]["Approved_by"].ToString().Trim() == "8")
            {
                lbl_seal.Text = "Assistant Director of Agriculture";
                lbltplace.Text = dt.Rows[0]["TName"].ToString().Trim();
                lbldplace.Text = dt.Rows[0]["DName"].ToString().Trim();
            }
            else
            {
                lbl_seal.Text = "Joint Director of Agriculture";
                //lbldplace.Text = dt.Rows[0]["DName"].ToString().Trim();
            }

            DateTime today = DateTime.Today;
            lblname.Text = dt.Rows[0]["App_Name"].ToString().Trim();
            lblpname.Text = dt.Rows[0]["Sales_Adress"].ToString().Trim();
            lblrespon.Text = dt.Rows[0]["Responsible_person"].ToString().Trim();
            lblradres.Text = dt.Rows[0]["Respo_Adres"].ToString().Trim();
            ////lblrespoaadar.Text = dt.Rows[0]["Respo_adhar"].ToString().Trim();
            lblemail.Text = dt.Rows[0]["Respo_email"].ToString().Trim();
            lblmob.Text = dt.Rows[0]["Respo_Mob"].ToString().Trim();
            lblgeneDate.Text = dt.Rows[0]["Generated_Date"].ToString().Trim();


        }

    }
1

There are 1 best solutions below

3
sm101 On

This normally happens when the page is embedded in a master page and that page also has a form tag. It's quite difficult to say since i don't have an idea about the project structure. But here are few tips. Since you say you haven't attached any master page could you please check whether the page is set to be attached into any _Layout.aspx or any other layout page. In MVC when you create pages there is a option to ad your page within a layout page.

As a work around I suggest you remove the existing form tags from the page and see how the page is rendered.