Showing posts with label AJAX. Show all posts
Showing posts with label AJAX. Show all posts

Friday, July 17, 2009

Setting Focus After AJAX Postback

This one really pissed me off. It should be easy to set the focus of a control after a postback in an AJAX Panel, right? In fact, if I searched Bing (you heard me) for "set focus after ajax postback" you'd think I would find this code. Not so much. It only took a week and a day to find this code:

ScriptManager.GetCurrent(this.Page).SetFocus(control);


...where "control" is the name of the control. Granted, this assumes an ASP.NET 3.5 application with a ScriptManager on the page. Done.