I'm doing a job for college, an application web forms in Asp.net C #. I'm having a problem and so far everything was fine, but out of the blue is giving this error. I looked for some related things, and this piece ended up "showing" my web page, but it does not take any action:
public override void VerifyRenderingInServerForm(Control control){ }
Error and exceptions:
Control 'ContentPlaceHolder1_Name' of type 'TextBox' should be inserted in a format tag with runat = server.
Description: An unhandled exception occurred during the execution of the current Web request. Examine the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'ContentPlaceHolder1_Name' of type 'TextBox' should be inserted into a format tag with runat = server.
Battery Tracking:
[HttpException (0x80004005): Control 'ContentPlaceHolder1_Name' of type 'TextBox' should be inserted in a format tag with runat = server.] System.Web.UI.Page.VerifyRenderingInServerForm (Control control) +9766490 System.Web.UI.WebControls.TextBox.AddAttributesToRender (HtmlTextWriter writer) +52 System.Web.UI.WebControls.WebControl.RenderBeginTag (HtmlTextWriter writer) +20 System.Web.UI.WebControls.TextBox.Render (HtmlTextWriter writer) +21 System.Web.UI.Control.RenderControlInternal (HtmlTextWriter writer, ControlAdapter adapter) +66 System.Web.UI.Control.RenderControl (HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl (HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal (HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren (HtmlTextWriter writer) +13 System.Web.UI.Control.Render (HtmlTextWriter writer) +12 System.Web.UI.Control.RenderControlInternal (HtmlTextWriter writer, ControlAdapter adapter) +66 System.Web.UI.Control.RenderControl (HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl (HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal (HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren (HtmlTextWriter writer) +13 System.Web.UI.Control.Render (HtmlTextWriter writer) +12 System.Web.UI.Control.RenderControlInternal (HtmlTextWriter writer, ControlAdapter adapter) +66 System.Web.UI.Control.RenderControl (HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl (HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal (HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren (HtmlTextWriter writer) +13 System.Web.UI.Page.Render (HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal (HtmlTextWriter writer, ControlAdapter adapter) +66 System.Web.UI.Control.RenderControl (HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl (HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1303
Code of my Login.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login_Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="panel panel-default" style="width: 450px; margin: 50px 50px 50px 600px; -webkit-box-shadow: 11px 10px 65px -4px rgba(0,0,0,0.59); -moz-box-shadow: 11px 10px 65px -4px rgba(0,0,0,0.59); box-shadow: 11px 10px 65px -4px rgba(0,0,0,0.59);">
<div class="panel-heading" style="text-align: center;">
<h1 style="font-weight: bold;">ENTRAR</h1>
</div>
<div class="panel-body" style="margin: 20px 50px 20px 100px;">
<p><span style="font-weight: bold">NOME</span></p>
<asp:TextBox ID="Nome" Width="200px" runat="server" CssClass="form-control" placeholder="Login" aria-describedby="basic-addon1"></asp:TextBox>
<span style="margin: 400px;"></span>
<p>
<span style="font-weight: bold">SENHA</span><br />
<asp:TextBox ID="Senha" Width="200px" TextMode="Password" runat="server" CssClass="form-control" placeholder="Senha" aria-describedby="basic-addon1"></asp:TextBox>
</p>
<asp:Button ID="Entrar" runat="server" OnClick="Entrar_Click" Text="Entrar" CssClass="btn btn-primary btn-success" />
</div>
</div>
<div style="text-align: center;">
<span style="margin: 50px;">
<asp:Label ID="Mensagem" runat="server" Visible="false" CssClass="alert alert-danger" role="alert"></asp:Label>
</span>
</div>
</asp:Content>
Login.aspx.cs
public partial class Login_Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected string conn = @"Data Source=PC-OSV;Initial Catalog=CadastroCompetencias;Integrated Security=True;";
AppDatabase.SqlServerTransaction db = new AppDatabase.SqlServerTransaction();
protected void Entrar_Click(object sender, EventArgs e)
{
if (ValidaUsuario(Nome.Text, Senha.Text))
{
// Inicializa a classe de autenticação do usuário
FormsAuthentication.Initialize();
//Define os dados do ticket de autenticação
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Nome.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, Session["Perfil"].ToString(), FormsAuthentication.FormsCookiePath);
// Grava o ticket no cookie de autenticação
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket)));
// Redireciona para a página do usuário
Response.Redirect(FormsAuthentication.GetRedirectUrl(Nome.Text, false));
}
else
{
Mensagem.Visible = true;
Mensagem.Text = "Oops... Login ou senha errados! Verifique se você não errou nada.";
}
}
/// <summary>
/// Autentica o usuário e retorna true se foi autenticado com sucesso
/// </summary>
protected bool ValidaUsuario(string nome, string senha)
{
db.ConnectionString = conn;
DataTable tb = (DataTable)db.Query("SELECT * FROM Usuarios WHERE NomeAcesso='" + Nome.Text + "' AND Senha='" + Senha.Text + "' AND Estatus=1;");
if (tb.Rows.Count == 1)
{
// Armazena na dados do usuário nas variáveis de sessão
Session["CodigoUsuario"] = tb.Rows[0]["CodigoUsuario"];
Session["NomeUsuario"] = tb.Rows[0]["NomeCompleto"];
Session["Perfil"] = "Administrador";
return true;
}
else
{
return false;
}
}
}
I count on your cooperation! Thank you in advance!