2012-02-21 45 views
0

我開發一個asp.net網站application.In該應用程序,我使用asyncRefresh事件 連續更新值。如果我使用的UpdatePanel的asyncRefresh事件將不會得到focus.Without updatepanel evet獲得焦點。我想用asynRefresh事件與updatepanel.Any一個請幫助解決這個問題。如何使用的UpdatePanel與AsyncRefresh事件

感謝&問候 Lijo托馬斯

回答

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; 
} 
相關問題