ASP.NET AJAX UpdatePanel scrolling problem

后端 未结 5 690
春和景丽
春和景丽 2021-01-24 00:16

I\'ll try and be concise:

  1. I have a dropdownlist with Autopostback set to true
  2. I have an UpdatePanel that contains a Label<
5条回答
  •  孤独总比滥情好
    2021-01-24 00:38

    public static void SetFocusByJavaScript(Page page, string clientID)
            {
                string uniqueScriptId = String.Concat("focusScript", clientID);
                string scriptBody = String.Format("setTimeout(\"$get('{0}').focus();\", 100);", clientID);
                ScriptManager.RegisterStartupScript(page, page.GetType(), uniqueScriptId, scriptBody, true);
            }
    

    This is how I have been getting around this issue. The example requires jquery, but you could rewrite if needed. Basically just delays the focus script.

提交回复
热议问题