Error runat=server when inserting a button into the form

Asked

Viewed 4,742 times

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.]      

As I already identified that would be the buttons that do not let start: Asp:Button

Soon I tested with other containers and also give the same error, I could not find solution for this, except using another type, for example html, but as I am developing in Asp.net c# would not make much sense to use it since I will do all back in c#. I’d like to know a way to fix that:

<%@ 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>

1 answer

2


With the ASP.Net Webforms, all server controls (runat="server") should be within a tag <form runat="server">.

To solve your problem, insert your page content into a <form runat="server">.

The problem with that is that you cannot have other tags <form> nestled. 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 tag <form>, will have to use the ASP.Net MVC.

  • 1

    This is what we develop a system for an emergency healthcare network in an unknown language :/. Thanks man kkkkk It worked

  • Great! Since the answer was helpful, don’t forget to take it for granted. Read more at http://answall.com/help/someone-answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.