I'd been using the hookonfocus method from this article: http://www.codeproject.com/KB/aspnet/MainatinFocusASPNET.aspx
to maintain focus during postbacks for certain .aspx pages. However, I've noticed that several pages (and some very simple pages in a test project) don't include the hidden field __LASTFOCUS. I'm trying to figure out which options I'm missing that will cause this hidden field to show up and be used to restore focus if I use javascript to keep __LASTFOCUS up to date when focus changes happen in an ASPX page.
Note: I'm using VS 2005/.Net 2.0 in case that makes a difference.
The
__LASTFOCUS
field is created byPage.RegisterFocusScript()
, which is called from...Page.SetValidatorInvalidControlFocus
) to focus controls that fails validationIt is also called in the OnPreRender method of CheckBox, ListControl and TextBox (and any derivatives). I'm guessing that the pages that does not output the
__LASTFOCUS
field does not contain any variant of these three controls.