469,632 Members | 1,622 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

the mystery of a default button

This is quite serious - for a beginner...
No property setting for a default button? I just want a button on a search
page to automatically be pressed when I hit the return/enter key.

Somehow I did it with one of my 2 buttons, (but I don't know how)
one of the buttons (cmdClear) decided on its own to be the default button -
instead of the cmdSearchMember button - so much so that even after searching
and finding 2 other solutions:
1) 'RegisterHiddenField("__EVENTTARGET", "cmdSearchMember")
2) Javascript -that ends up with:
SetDefaultButton(Me.txtNAME_ID, cmdSearchMember) in the load event of
the form.

.... the other button (cmdClear) continues to be selected and is
automatically pushed when I hit the enter (return) key.

Please help, I know the solution isn't to grab my code from the
cmdSearchMember button and add it to the cmdClear button - although that is
becoming quite tempting.

Dec 25 '05 #1
2 1161
If you are in 2.0, you do have property DefaultButton.

In 1.1 the first button on the form is always the default one.

Eliyahu

"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
This is quite serious - for a beginner...
No property setting for a default button? I just want a button on a
search
page to automatically be pressed when I hit the return/enter key.

Somehow I did it with one of my 2 buttons, (but I don't know how)
one of the buttons (cmdClear) decided on its own to be the default
button -
instead of the cmdSearchMember button - so much so that even after
searching
and finding 2 other solutions:
1) 'RegisterHiddenField("__EVENTTARGET", "cmdSearchMember")
2) Javascript -that ends up with:
SetDefaultButton(Me.txtNAME_ID, cmdSearchMember) in the load event of
the form.

... the other button (cmdClear) continues to be selected and is
automatically pushed when I hit the enter (return) key.

Please help, I know the solution isn't to grab my code from the
cmdSearchMember button and add it to the cmdClear button - although that
is
becoming quite tempting.

Dec 25 '05 #2
Hi Jonefer,

You do not have to switch the code in your buttons. In ASP.NET 1.1, you may
still create a webpage with more than one section in it; each section can
have the equivalent of a "default" by adding a few lines of JavaScript to
attach the event OnKeyPress of each textbox to trigger a different button's
Click event. For a demo take a look at this sample:
http://www.societopia.net/samples/ASPPage_Buttons.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"jonefer" wrote:
This is quite serious - for a beginner...
No property setting for a default button? I just want a button on a search
page to automatically be pressed when I hit the return/enter key.

Somehow I did it with one of my 2 buttons, (but I don't know how)
one of the buttons (cmdClear) decided on its own to be the default button -
instead of the cmdSearchMember button - so much so that even after searching
and finding 2 other solutions:
1) 'RegisterHiddenField("__EVENTTARGET", "cmdSearchMember")
2) Javascript -that ends up with:
SetDefaultButton(Me.txtNAME_ID, cmdSearchMember) in the load event of
the form.

... the other button (cmdClear) continues to be selected and is
automatically pushed when I hit the enter (return) key.

Please help, I know the solution isn't to grab my code from the
cmdSearchMember button and add it to the cmdClear button - although that is
becoming quite tempting.

Dec 25 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Lovely Dola | last post: by
8 posts views Thread by Al Reynolds | last post: by
reply views Thread by William Wisnieski | last post: by
3 posts views Thread by GaryDean | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.