Setting Control Focus in an Ajax Update Panel

I’ve decided to start posting the solutions I find in irritating little problems that take me forever to find.  Some of these will probably be obvious, but hopefully it might save someone’s time.  My current problem was that I had a DotNetNuke module that was sitting in a AJAX Update Panel.  I needed to set the focus to a particular control based upon a post back click on a radio button.  The standard focus() method didn’t work and neither did the old fashioned RegisterClientScriptBlock stuff with a provided JavaScript function.  Turns out there is an extremely easy way to do this which is to use the ScriptManager SetFocus method using the base Page for the control as shown below:

ScriptManager.GetCurrent(Me.Page).SetFocus(txtApplicationDate)

Hope that helps someone.

4 thoughts on “Setting Control Focus in an Ajax Update Panel

  1. hello
    i am appreciating from your help
    but i have another problem
    when the focus send to textbox the mouse curser comes to start of
    the text.
    thank you

Leave a Reply