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

15,874

Master pages should not contain form tags in general because they are meant to be used only as the base layout of your content page. Remove the form tag from the Master page and the error will go away.

If you want to define a common "Login" section for all your pages (this appears to be your intent), you can instead create a UserControl to do this. You would then define a section inside your Master page to contain this user control making sure that the ContentPlaceHolder of the Login UserControl always ends up enclosed inside the content page's form. That way, when you submit the form, the btnlogin_Click1 click event is triggered.

In conclusion: re-arrange your page in a way that you have one form tag per page, since ASP.NET does not allow having more than one and try to define your form's inside the content pages and not the Master page.

Share:
15,874
user2132564
Author by

user2132564

Updated on June 14, 2022

Comments

  • user2132564
    user2132564 almost 2 years

    Masterpage.aspx

        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
    
        </asp:ContentPlaceHolder>
        <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'>     
         </script>
         <script src="Chrome.js" type="text/javascript"></script>
         </head>
         <body>
         <form id="Master" runat="server">
          <table style="width:987px; margin:auto; height: 86px;">
           <tr style="background-color:#FFFFFF">
             <td class="style2">
               <img src="images/logo.jpg" alt="" width="235" height="73" />&nbsp;
                 </td>
                 <td style="vertical-align:middle;"class="style1">
                 <div style="float:right; width:153px; height: 22px;">
                 &nbsp;<asp:TextBox ID="TextBox1" runat="server" Height="20px" 
                                                style="margin-left: 0px" Width="140px">   
                  </asp:TextBox>
                  </div>
                  <a href="">Forget Password?</a> </span></span>
                   </td>
                   <td class="style33">
                  <div style="float:right; width:157px; height: 20px; margin-right: 1px;">
                <asp:TextBox ID="TextBox2" runat="server" Height="20px"  
                                                style="margin-left: 0px; margin-top:  
                                                Width="147px"></asp:TextBox>
                                            </div>
    
                  <a href="Registration.aspx">New User Registration</a> </span>
                                    </td>
                                    <td class="style40">
                <div style="height: 67px; width: 81px;">
                &nbsp<asp:Button ID="btnlogin" runat="server" style="color:White;  background-color:#404040;font-family:Verdana;font-size:10pt; height: 29px; margin-top: 12px;" Text="Login" onclick="btnlogin_Click1" /></div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr style="background-color:#207DA8">
                        <td class="style39">
                        </td>
                        <td class="style39">
                        </td>
                    </tr>
    
    
    
            <script type="text/javascript">
    
                cssdropdown.startchrome("chromemenu")
    
              </script>
                        </td>
                    </tr>
    
                                            <img alt="" src="images/rgt.jpg" style="width: 471px; height: 247px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        </td>
                                    </tr>
                                    <tr style="vertical-align=top;background-color=#D4D3D9">
                                        <td style="height:1;">
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                             </tbody>
                             </table>
           <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
       </form>  
      </body>
      </html>
    

    RegisterPage.aspx

      <%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" ValidateRequest="false" Inherits="Paragraphreader.Registration" %>
      <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
       <script src="jquery.validate.js" type="text/javascript"></script>
       <script src="jquery.validation.js" type="text/javascript"></script>
        <script>
        $("#Register").submit(function () {
            return $(this).validation();
            alert("submitted");
        });
    
     </script>
     <script>
         function validate() {
    
             var a = 0, rdbtn = document.getElementsByName("gender");
             for (i = 0; i < rdbtn.length; i++) {
                 if (rdbtn.item(i).checked == false) {
                     a++;
                 }
             }
    
             if (a == rdbtn.length) {
                 document.getElementById("RadioButtonList1").style.border = "2px solid red";
                 return false;
             } else {
                 document.getElementById("RadioButtonList1").style.border = "";
                 return true;
             }
    
         }
    
     </script>
    
       <link href="Career.css" rel="stylesheet" type="text/css" />
       <link href="Chrome.css" rel="stylesheet" type="text/css" />
       <link href="Styles.css" rel="stylesheet" type="text/css" />
      <form id="Register" runat="server">//A page can have only one form tag
      <asp:ScriptManager ID="ScriptManager1" runat="server">
      </asp:ScriptManager>
      <asp:UpdatePanel ID="FormUpdatePanel" runat="server">
       <ContentTemplate>
    

    I am getting error(A page can have only one server side cof while compiling RegisterPage.aspx.In the master page i have a form tag and server side code In the Register page i have a form tag and server side code.how to avoid this error