1
代码第一:C#的ImageButton Click事件不会触发
public class ExtendedGridView : GridView
{
private ImageButton m_btnPrint;
public ImageButton PrintButton
{
get { return m_btnPrint; }
set { m_btnPrint = value; }
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
PrintButton = new ImageButton();
PrintButton.Click += new ImageClickEventHandler(OnPrintButtonClick);
PrintButton.AlternateText = "Print";
PrintButton.ImageUrl = "../../Images/Print.png";
TableCell cell = new TableCell();
cell.Controls.Add(PrintButton);
cell.ColumnSpan = this.FooterRow.Cells.Count;
this.FooterRow.Cells.Clear();
this.FooterRow.Cells.Add(cell);
}
public void OnPrintButtonClick(object sender, ImageClickEventArgs e)
{
// Do Stuff
}
}
这段代码的目的是取代页脚内容与图像按钮,它这样做的罚款。这个计划是在同一个类中处理click事件,但是我不能让OnPrintButtonClick方法去,它不会在那里突破。但是,该页面似乎正在回发。在这个网站上有过这个问题,但我还没有看到答案。 在此先感谢
OnPrintButtonClick被连接在哪里? –