如何檢查一個動態創建的控件是否回發?下面的代碼不起作用。asp.net:如何檢查一個動態創建的控件是否回發
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;
}
if (c is System.Web.UI.WebControls.ImageButton)
{
control = c;
break;
}
}
}
return control;
我在page_Init上創建了一些圖形按鈕。但是上面的代碼總是返回null。這是爲什麼?如何檢查圖像按鈕是否已回傳?
注意:我能夠處理這些圖像按鈕的點擊事件。
我不跟着你。你是什麼意思「檢查圖像按鈕是否回傳」?你正在處理的點擊事件是後備,不是嗎? – tiago2014 2011-03-07 04:33:36
您是否得到了解決方案? – Lijo 2013-01-23 18:49:54