¿En ASP.NET cómo puedo identificar el control del evento de tipo Postback en la carga del documento?
¡
identificar evento de tipo Postback
Iniciado por
Julian10
, abr 02 2014 17:57
#1 AUTOR PREGUNTA
Esto también te interesa!
#2
Publicado 03 abril 2014 - 03:00
Con el siguiente código puedes obtener el control que causo el Postback:
public static Control GetPostBackControl(Page page)
{
Control control = null;
string ctrlname = page.Request.Params.Get("__EVENTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
control = page.FindControl(ctrlname);
}
else
{
foreach (string ctl in page.Request.Form)
{
Control c = page.FindControl(ctl);
if (c is System.Web.UI.WebControls.Button)
{
control = c;
break;
}
}
}
return control;
}