1
I have a .aspx
where I put a div
alert. I have a class Message
to handle system messages. To treat these messages when instantiating the class, step as parameter to page, in the method step as parameter the message and message type. But the Page.findcontrol("alert")
is returning to me null
and I can’t 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");
}