我已定义此方法,因为我将向长表中的每一行添加一个链接按钮。但是它不会调用eventHandler。它确实会导致asyncPostback,但从不调用eventHandler。
public static void InsertLinkButton(string text, string id, EventHandler eventHandler,
UpdatePanel updateSummary, PlaceHolder placeHolder)
{
LinkButton link = new LinkButton();
link.Text = text;
link.Click += eventHandler;
link.CausesValidation = false;
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = link.ID = "link" + id;
trigger.EventName = "Click";
Utils.Tag(link, placeHolder);
updateSummary.Triggers.Add(trigger);
}
事件处理程序的签名:
protected void link_Click(object sender, EventArgs e)
{
//check which link clicked me and do stuff
}
我会用这个方法调用这个方法:
InsertLinkButton("Division", "Division", link_Click, updateSummary, placeHolderSummary);
此代码中的内容是否有误?或者我的问题是其他的吗?