Friday, January 07, 2005

Click Button on Enter in TextBox (ASP.NET)

DefaultTextBoxControl is an ASP.NET Web Control that you can use to specify which button to 'click' on a form when a user presses Enter when focused on a text box (otherwise the first button in the form gets 'clicked'). You have to replace TextBox controls with DefaultButtonTextBox and add DefaultButtonControl. Works with LinkButton and Button.

DefaultButtons (by Andy Smith of MetaBuilders) also does the same thing (without the need to change any controls, just add extra tags at start of page/user control), but only works on Button controls for submitting.

Does not solve the accessibility issue (if it is even solvable) when JavaScript is disabled (as ASP.NET pages can only have one server form on a page).

No comments: