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:

    ofButtonLogin.Focus();
    ofTextUserName.Focus();

To change the default button, depending on which data entry element has focus, the easiest way is JavaScript. See Darrell Norton's approach at http://codebetter.com/blogs/darrell.norton/archive/2004/03/03/8374.aspx.

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]