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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top