Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

ASP.NET 2.0 AND DefaultButton?

This is a long question, so be prepared...

I am working with an ASP.NET 2.0 web application. I have a form with a textbox, a cancel button, and a continue button. I want the continue button to be the default, and I want th textbox to have the focus when the form loads. I set the form DefaultButton and DefaultFocus attributes to btnContinue and txtTextBox repsectively.

When the form loads, the cursor is in the textbox, but the cancel button has the emphasized border. When I hit the enter key, the continue button fires like I expect. The problem is that the cancel button LOOKS like it is the default.

I trued using JavaScript to set the focus to the continue button. This is okay, but then, when the user clicks in the textbox, the cancel button again has the emphasized border. Again, the enter key press will fire the continue button as expected.

Am I crazy, or is this harder than it should be? Any help would be greatly appreciated.

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    Have you tried giving it a lower tab index, when you created the form perhaps you put the cancel button on before the continue and it's tab index comes first. I haven't ran it to this problem before, so I'm not sure if that will solve it.

Still have questions? Get your answers by asking now.