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 responses to “Setting Control Focus in an Ajax Update Panel”
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
Well I don’t know off the top of my head, but I would guess you could use the same process to set the index of the textbox or something like that.
It Works. Clean Solution & very useful
Thanks a Lot!!!!!
Thank you. So simple.