ASP.NET 2.0 does great things but like its ancestors also has holes: things we need to do but can't -- or can't without dodging around it with inside knowledge, JScript and other tricks. AspNet2Holes is about those holes and the ways to step around them.

Wednesday, June 14, 2006

Setting a default button with default input focus

Microsoft has not documented how to set a default button through ASP.NET 2.0 when a page also has data entry elements that need a default focus. It's easy, though. Before rendering the page, set focus on the default button, then on the default data entry element. For example, in the Page_Load function:

About Me

Craig BolonCommercial software development over 25 years in Windows and Linux, before that in DOS, Unix, VMS and several others, more than 20 languages. Working now mostly in ASP.NET with C#, SQL and JavaScript.
View my complete profile