I'm trying to show a modal, when clicking on a dynamically created button.
If I have it this way it runs but it immediately disappears and I can not do anything since the page goes gray.
<script>
function ModalGood() {
$("#engModal").modal();
};
</script>
but if I have it this way it simply sends a JavaScript error
<script>
$(document).ready(function () {
$("").click(function () {
$("#myModal").modal();
});
});
</script>
and this is my code of how I create the button on how I try to execute it when I click on the button created
protected void Unnamed1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showAndHide();", true);
Button Btn_clic = (Button)sender;
var name = Btn_clic.Text;
List.ListUsers listArea = new List.ListUsers();
List<Data.Area> Area = listArea.AreaList();
List<Data.Area> ListOfEquiposFCHOk = Area.Where(x => x.AREA == name && x.STANDBY == 0).ToList();
List<Button> Botones = new List<Button>();
var TeamFCH = ListOfEquiposFCHOk.Select(x => x.TEAM).Distinct().ToList();
foreach (var team in TeamFCH)
{
Button newButton = new Button();
newButton.ID = "Btn_" + Convert.ToString(team);
newButton.Text = team;
newButton.Click += new EventHandler(Info_Click);
newButton.OnClientClick = "ModalGood();";
Botones.Add(newButton);
GoodPanel.Controls.Add(newButton);
newButton.CssClass = "btn-primary outline separate";
}
}
In the second example I decided to leave it blank because I do not know how to give the id that is generated dynamically