我有以下代码:
当我点击
protected void Page_Load(object sender, EventArgs e)
{
using (ImageButton _btnRemoveEmpleado = new ImageButton())
{
_btnRemoveEmpleado.ID = "btnOffice_1";
_btnRemoveEmpleado.CommandArgument = Guid.NewGuid().ToString();
_btnRemoveEmpleado.Height = 15;
_btnRemoveEmpleado.Width = 15;
_btnRemoveEmpleado.ImageUrl = "cross-icon.png";
_btnRemoveEmpleado.Click += new ImageClickEventHandler(_btnRemoveEmpleado_Click);
this.phPartesPersonal.Controls.Add(_btnRemoveEmpleado);
}
}
void _btnRemoveEmpleado_Click(object sender, ImageClickEventArgs e)
{
try
{
string s = "";
}
catch (Exception ex)
{
}
finally { }
}
当我点击
_btnRemoveEmpleado
时,会执行 postback 但永远不会到达 string s = "";
这一行。请问如何执行 _btnRemoveEmpleado_Click
的代码?
AutoPostBack = true
吗? - DavidGImageButton
中使用using
块。因为在using
块之后,该按钮将被处理,无法处理事件。请参考:http://stackoverflow.com/questions/21316266/event-handler-stops-working-after-dispose - mshsayem