Set focus to a TextBox (in a ModalPopupExtender)
I have a web page where couple of ModalPopupExtender and Panel exist, and I want to set focus to TextBox inside the corresponding pop up window when user click the target button accordingly. I think it's a common requirement to set the focus to a specific TextBox immediately when user open up the window. However, I always get the error message "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus".
Understand that the modal pop up window and the TextBox inside are hidden by default, while setting focus on that TextBox upon the click of TargetControl seems impossible. Fortunately, google showed me an article by Jaspreet and he showed how he solve this problem by using the setTimeOut and two JavaScript functions (set the focus by 1 second delay).