我正在开发一个asp.net web应用程序。在该应用程序中,我正在使用asyncRefresh事件 如果我正在使用updatepanel,asyncRefresh事件将无法获得焦点。没有updatepanel evet获得焦点。我想使用updatepanel的asynRefresh事件。任何一个请帮助解决这个问题。
感谢和安培;问候 Lijo Thomas
答案 0 :(得分:0)
protected void Page_Load(object sender, EventArgs e)
{
object et = Request.Form["__EVENTTARGET"] as object;
if (et != null)
{
Control c = Page.FindControl(et.ToString());
if (c != null)
{
ScriptManager.GetCurrent(this).SetFocus(GetUniqueIdSmart(c));
}
}
}
protected static string GetUniqueIdSmart(Control control)
{
string id = control.UniqueID.Replace('$', '_');
string controlIDSuffix = "";
RadioButtonList rbl = control as RadioButtonList;
if (rbl != null)
{
controlIDSuffix = "_0";
int t = 0;
foreach (ListItem li in rbl.Items)
{
if (li.Selected)
{
controlIDSuffix = "_" + t.ToString();
break;
}
t++;
}
}
else if (control is CheckBoxList)
{
controlIDSuffix = "_0";
}
id += controlIDSuffix;
return id;
}