I have the following code inside the CS file of the page, i am trying to add an html button inside a div in the server side to close the alert modal dialog. When I add the event to the button and try to fire it. The event doesn't fires. So, where is the problem ?
public Alert(HtmlGenericControl alert ,string alertMessage)
{
vAlert = alert;
alert.Attributes.Add("class", "uk-modal");
alert.Attributes.Add("aria-hidden", "true");
alert.Attributes.Add("style", "display: none; overflow-y: scroll;");
HtmlGenericControl innerDiv = new HtmlGenericControl();
innerDiv.TagName = "div";
innerDiv.Attributes.Add("class", "uk-modal-dialog");
innerDiv.Attributes.Add("style", "top: 35.5px;text-align:center; padding:30px;");
HtmlInputButton btnclose = new HtmlInputButton();
btnclose.Attributes.Add("type", "button");
btnclose.Attributes.Add("id", "alert_close");
btnclose.Attributes.Add("runat", "server");
btnclose.Attributes.Add("class", "uk-modal-close uk-close");
btnclose.Attributes.Add("style", "padding:15px;");
btnclose.ServerClick += new EventHandler(btnclose_ServerClick);
innerDiv.Controls.Add(btnclose);
HtmlGenericControl p = new HtmlGenericControl();
p.TagName = "p";
p.InnerText = alertMessage;
innerDiv.Controls.Add(p);
alert.Controls.Add(innerDiv);
ShowAlert(alert);
}
private void btnclose_ServerClick(object sender, EventArgs e)
{
HideAlert(vAlert);
}
Can you help me ?
Page_Init