setting default button

  • Thread starter Thread starter Richard Roche
  • Start date Start date
R

Richard Roche

What are the ways to set default (activiated on enter)
status for buttons?

i've tried:
TabIndex
and
Page.RegisterHiddenField("__EVENTTARGET", "cmdWhatever")

but the first button seems to be default always. I must
be missing something.

Thanks for any assistance.
 
Seems there is no way to use multiple forms in ASP.NET. And there is no easy
way to deal with multiple buttons in a single form.

I found javascript to be helpful in solving this problem:

<input type="text" onkeydown="if(event.keycode==13){targetButton.click();
return false;}"/>
 
Page.RegisterHiddenField("__EVENTTARGET", "ButtonID") should work.
But it works only if you have html button(<input type=submit>) type buttons.
It won't work if you have <asp:Button> objects in your page.

Hope this helps,
 
Back
Top