简体   繁体   中英

A page can have only one server side form tag

I have a master page Header.master which contains a logout button, due to this reason I have to include a form with run at server in my master form.

Again I am using a form in my page because I want to use controls and asp.net compiler says that you cant use controls with form tag with run at server.

Header.master

<form runat="server"><asp:ImageButton ID="btn_logout" runat="server" OnClick="btn_logout_Click" Height="22px" ImageUrl="~/img/logout.png" Width="43px" /></form>

My Page

<%@ Page Title="" Language="C#" MasterPageFile="~/Header.Master" AutoEventWireup="true" CodeFile="student_registration.aspx.cs" Inherits="SCMS.student_registration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form id="frm_sr" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
</asp:UpdatePanel>
</form>
</asp:Content>

Remove Form tag from your page (My Page)

<form id="frm_sr" runat="server">

Form tag in master page is already enclosing all the code written in page itself

(<asp:Content ID=...>)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM