The TextBoxWatermarkExtender removes focus from a textbox when focus was set using code behind .focus()
I looked at the src for TextBoxWatermarkExtender (thank you for providing source!!!) and it's checking for 'Page.Form.DefaultFocus' - it would appear than 'control.focus()' doesn't set Page.Form.DefaultFocus, so the TextBoxWatermarkExtender is not recognising the .focus() call.
Example attached, reproduction:
New web form
Add two textboxes (to focus on second)
Add TextBoxWatermarkExtender to second
In Page_Load, add: secondTextBox.Focus()
Result: Focus is not preserved.
Clunky work-around: Instead of secondTextBox.Focus(), have to use: Me.Form.DefaultFocus = secondTextBox.ClientID
This might be considered a bug with .Focus(), but the AJAX Control Toolkit would probably get updated sooner....
Comments: This ticket was filed for a pre-15.1 version of AJAX Control Toolkit. If this is still an issue in v15.1 or later, please create a new inquiry.
I looked at the src for TextBoxWatermarkExtender (thank you for providing source!!!) and it's checking for 'Page.Form.DefaultFocus' - it would appear than 'control.focus()' doesn't set Page.Form.DefaultFocus, so the TextBoxWatermarkExtender is not recognising the .focus() call.
Example attached, reproduction:
New web form
Add two textboxes (to focus on second)
Add TextBoxWatermarkExtender to second
In Page_Load, add: secondTextBox.Focus()
Result: Focus is not preserved.
Clunky work-around: Instead of secondTextBox.Focus(), have to use: Me.Form.DefaultFocus = secondTextBox.ClientID
This might be considered a bug with .Focus(), but the AJAX Control Toolkit would probably get updated sooner....
Comments: This ticket was filed for a pre-15.1 version of AJAX Control Toolkit. If this is still an issue in v15.1 or later, please create a new inquiry.