I have .aspx
where I put a div
alert. I have a Message
class to handle the system messages. To treat these messages when instantiating the class, I pass as parameter the page, in the step method as parameter the message and message type. But Page.findcontrol("alert")
is returning me null
and I can not understand why.
.aspx:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="row">
<div id="alert">
</div>
</div>
</asp:Content>
Code-behind:
Message mensagens = new Message(this);
mensagens.ShowMensagem("mensagem", "alerta");
Message.cs:
private Page pagina;
public Message(Page pagina) {
this.pagina = pagina;
}
public void ShowMensagem(string mensagem, string tipo){
System.Web.UI.HtmlControls.HtmlGenericControl div = (System.Web.UI.HtmlControls.HtmlGenericControl)pagina.FindControl("ContentPlaceHolder1_alert");
}