Runat = server error when inserting a button in the form

2

I have this problem that when passing the login form it gives this error:

[HttpException (0x80004005): Controle 'Button1' do tipo 'Button' deve ser inserido em uma marca de formato com runat=server.]      

I have tried other containers and also the same error, I could not find a solution for this, using another type, for example html, but as I am developing in ASP.NET C # it would not make much sense to use it since I'm going do everything back in C #. I would like to know a way to resolve this:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mapa.aspx.cs" Inherits="MapaAs.mapa" %>

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="stylesheet" href="css/style.css" media="screen"/>
 <link rel="stylesheet" href="css/botao.css" media="screen"/>
 <link rel="stylesheet" href="css/all-animation.css">
 <script src="java/jquery-1.11.1.js"></script>
 <title>MAPA DE LEITOS ALPHA</title>
<style type="text/css">

     </style>
 </head>
  <body>
   <script src="java/tooltip.js"></script>

    <div id="section" runat=server>
            <div id="header">


            <form id="logoSBC">
            </form>
            <form id="logoUPA">
            </form>

            <div id="cabeca2">
            UPA ALVES DIAS
            </div>
            </div><!--Fim da header--><!--onMouseOver="toolTip('Lag', 150,100)" onMouseOut="toolTip()"-->
        <div id="navleitos">    
            <asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="False" />
        </div><!--FINAL LEITOS-->

<div id="Plantoes" style="display:none">
    <asp:Table ID="plantao" runat="server" Width="86px">
<asp:TableRow>
    <asp:TableCell>
        <asp:Label ID="Label1" runat=server Text="Médicos:"></asp:Label>
    </asp:TableCell>
</asp:TableRow>
    </asp:Table>
    </div>


 </div><!--FIM DA VIDA-->
 </body>
</html>
    
asked by anonymous 13.05.2015 / 23:05

1 answer

1

With ASP.Net WebForms , all server controls ( runat="server" ) must be inside a <form runat="server"> tag.

To resolve your issue, insert the content of your page into <form runat="server"> .

The problem with this is that you can not have other <form> tags nested. There are some hacks to allow more than one form with WebForms, but conceptually this is not allowed. If you really need to have more than one <form> tag, you will need to use ASP.Net MVC .

    
13.05.2015 / 23:16