Sub App_Start
TxtHidden.Visible=False
TxtHidden.Focus
'Focus doesn't change
End Sub
Sub Somethinghappens
TxtHidden.Focus
'Focus doesn't change
End Sub
Sub Txt_GotFocus
'Do something
End Sub
In my case, I use a dummy textbox to keep the focus off the main search box when it's not in use. When the search box is focused, the text color changes from gray to black, the "Type something here" is erased and the current controls make place to search options. However since I can't set focus to another box while testing, this breaks the whole thing as the search box always regains focus, returning to search options instead of showing the search results.
My temporary fix is the following:
If CPPC=True Then TxtHidden.Visible=False
This way I can test without problems.