473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

making a button the default?

Didn't there used to be some property where you could set a button to be the
"default" so that if a user pressed enter with any control in focus, the
button would still get the click event? Some way you could set it as the
"cancel" button too, wasn't there?

Anyway, can you do this with windows forms button?

Thanks in advance!

Derrick
Nov 16 '05 #1
7 8544
Derrick wrote:
Didn't there used to be some property where you could set a button to be the
"default" so that if a user pressed enter with any control in focus, the
button would still get the click event? Some way you could set it as the
"cancel" button too, wasn't there?

Anyway, can you do this with windows forms button?


Yes, the property is on the form, not the button. After adding the
button to the form, on the form set the AcceptButton property on the
form. You also have a CancelButton property.
--
Tom Porterfield
Nov 16 '05 #2
Tom,

Thanks, should have mentioned this is a "UserControl". I don't see an
AcceptButton property, is that something not available on a control?

Thanks again!

Derrick
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:u7**************@TK2MSFTNGP15.phx.gbl...
Derrick wrote:
Didn't there used to be some property where you could set a button to be the "default" so that if a user pressed enter with any control in focus, the
button would still get the click event? Some way you could set it as the "cancel" button too, wasn't there?

Anyway, can you do this with windows forms button?


Yes, the property is on the form, not the button. After adding the
button to the form, on the form set the AcceptButton property on the
form. You also have a CancelButton property.
--
Tom Porterfield

Nov 16 '05 #3
Is there also a way to do this for ASP.Net forms?

"Tom Porterfield" wrote:
Derrick wrote:
Didn't there used to be some property where you could set a button to be the
"default" so that if a user pressed enter with any control in focus, the
button would still get the click event? Some way you could set it as the
"cancel" button too, wasn't there?

Anyway, can you do this with windows forms button?


Yes, the property is on the form, not the button. After adding the
button to the form, on the form set the AcceptButton property on the
form. You also have a CancelButton property.
--
Tom Porterfield

Nov 16 '05 #4
Derrick wrote:
Tom,

Thanks, should have mentioned this is a "UserControl". I don't see an
AcceptButton property, is that something not available on a control?


That property is not in Control. For a user control you would need to
handle the key press event for the control looking for the enter or esc
key and behave accordingly.
--
Tom Porterfield
Nov 16 '05 #5
"Derrick" <de*********@excite.com> wrote:
[default and cancel buttons]


Form has AcceptButton and CancelButton properties.

P.
Nov 16 '05 #6
It's not built into ASP.Net, but there's an excellent freely available
control from Metabuilders that does this and more:

http://www.metabuilders.com/Tools/DefaultButtons.aspx

--
-Philip Rieck
http://philiprieck.com/blog/

-
"tleforge" <tl******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Is there also a way to do this for ASP.Net forms?

"Tom Porterfield" wrote:
Derrick wrote:
> Didn't there used to be some property where you could set a button to
> be the
> "default" so that if a user pressed enter with any control in focus,
> the
> button would still get the click event? Some way you could set it as
> the
> "cancel" button too, wasn't there?
>
> Anyway, can you do this with windows forms button?


Yes, the property is on the form, not the button. After adding the
button to the form, on the form set the AcceptButton property on the
form. You also have a CancelButton property.
--
Tom Porterfield

Nov 16 '05 #7
Derrick,
The form's AcceptButton is looking for the IButtonControl interface, if your
UserControl implements IButtonControl and responds appropriately, you should
be able to have a button on your control or the control itself behave as the
Enter (Accept) button for the form.

With effort you might be able to have 2 buttons on a UserControl behave as
the Enter & Cancel buttons for the Form, however I'm not sure how I would
set the respective properties...

Hope this helps
Jay

"Derrick" <de*********@excite.com> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl...
Tom,

Thanks, should have mentioned this is a "UserControl". I don't see an
AcceptButton property, is that something not available on a control?

Thanks again!

Derrick
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:u7**************@TK2MSFTNGP15.phx.gbl...
Derrick wrote:
> Didn't there used to be some property where you could set a button to
> be the > "default" so that if a user pressed enter with any control in focus,
> the
> button would still get the click event? Some way you could set it as the > "cancel" button too, wasn't there?
>
> Anyway, can you do this with windows forms button?


Yes, the property is on the form, not the button. After adding the
button to the form, on the form set the AcceptButton property on the
form. You also have a CancelButton property.
--
Tom Porterfield


Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dharmesh | last post by:
Hi every1, I have two buttons on a webform and I want to make one button as a default button. But when I view the page in browser its the wrong button which is getting the default property. ...
1
by: KKramsch | last post by:
I want the border color of this button to be the same as document.linkColor. How can I implement this? My best solution has been to have the onload handler for the page find the button and set...
6
by: deko | last post by:
I have a several forms that accept user input in a textbox and then take some action based on that input after a command button is clicked. Is it possible issue the command when the user presses...
2
by: Bratislav Jevtic | last post by:
hi, how to make some push button default on the form? for instance, I've got 2 buttons (Submit, Cancel). submit is on the left, cancel on the right side. on enter key pressed, cancel button is...
5
by: Martin Eyles | last post by:
I was hoping to style a link to look like a button using css. I thought I might be able to use something like display:button, but it appears this doesn't exist in the css 2.1 spec. I then looked at...
15
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this...
2
by: AlecL | last post by:
Hi All, I have added a user control onto an aspx page and want to make the submit button of that user control the default button when the panel in which the user control is located is visible. ...
0
by: Stefan Sonnenberg-Carstens | last post by:
Hi, I was wondering if there are any tricks around to do some sort of changing types, float in particular. I do many operations like summing etc on lots of floats and always have to do some extra...
3
by: divyaphilip | last post by:
Hi, I have a javascript function that uses ajax to set a div based on a query. The javascript function is invoked on a button click and uses ajax like this: function validDate(node,roomid) {...
2
Claus Mygind
by: Claus Mygind | last post by:
For my intranet web app we use exclusively FireFox as our browser. I have a report I want to format in the landscape mode and would like to include that code in the print button I display for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.