Ich habe eine Seite, die dynamisch eine Tabelle von Kontakten erstellen, wenn der Kontakt eine E-Mail bekam ich auch eine Bildschaltfläche mit einem Klick-Ereignis erstellen.Ich habe eine ähnliche Funktion im Rest der Seite, die perfekt funktioniert. Und ich habe dies vor ohne Probleme:Plötzlich wird das Klick-Ereignis von imagebutton nicht ausgelöst.
protected void CreateContactsList(IQueryable<AA_BranschFinder.Login.vyWebKontaktpersoner> lContacts) // Creates a table in the aspx from an IQueryable List
{
if (1 == 1)
{
htmlTblContactsContent.Rows.Clear();
foreach (var p in lContacts)
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell tdName = new HtmlTableCell();
HtmlTableCell tdCompanyName = new HtmlTableCell();
HtmlTableCell tdEmailAdress = new HtmlTableCell();
tdName.InnerHtml = p.strFnamn + " " + p.strEnamn;
tdCompanyName.InnerHtml = p.strNamn;
//Displays an image if the contacts has an email
if (p.strEpost != null)
{
ImageButton imgEmail = new ImageButton();
imgEmail.CommandArgument = p.intKundID.ToString();
imgEmail.ImageUrl = "images/symbol_letter.gif";
imgEmail.CssClass = "letter";
imgEmail.Click +=new ImageClickEventHandler(imgEmail_Click);
tdEmailAdress.Controls.Add(imgEmail);
}
tr.Cells.Add(tdCompanyName);
tr.Cells.Add(tdEmailAdress);
tr.Cells.Add(tdName);
htmlTblContactsContent.Rows.Add(tr);
}
}
}
void imgEmail_Click(object sender, ImageClickEventArgs e)
{
Breakpoint- hier throw new NotImplementedException(); }
Die Seite lebt in einem Java-Popup-Fenster. Aber ich habe Paging-Nummern mit ähnlicher Ereigniserzeugung, die gut funktioniert. Aber sie sind Linkbuttons.