473,698 Members | 2,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8559
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 "UserContro l". 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******** ******@TK2MSFTN GP15.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 "UserContro l". 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*********@ex cite.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******@discu ssions.microsof t.com> wrote in message
news:0A******** *************** ***********@mic rosoft.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*********@ex cite.com> wrote in message
news:Oj******** ******@tk2msftn gp13.phx.gbl...
Tom,

Thanks, should have mentioned this is a "UserContro l". 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******** ******@TK2MSFTN GP15.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
1159
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. So my question is , how can I make a button default button? Thank you very much.
1
1338
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 its style.borderColor attribute to the desired color. Is there a better way? Many thanks in advance, Karl
6
59275
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 Enter rather than clicking the command button? I've tried this, but for some reason it's not working: Private Sub txtFind_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Call cmdFind_Click End Sub
2
1593
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 processed - wrong. so, how to make a button default (when one presses ENTER then it's processed onClick event)? thanks, bj
5
15905
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 Appendix D to see how it is suggested it would be styled, and found just button, textarea, input, select { display: inline-block } I take it that the button-like look of buttons is therefore meant to be part of the content, and can't be...
15
12535
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 property. Where is it? Or mabye change the other thing,No?Thanks ! Simon
2
9830
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. I have used the code: Page.RegisterHiddenField("__EVENTTARGET", "Login.btnSubmit") in the Page Load event but this does not make the submit button default(enter) button. Any ideas on how can I do this. I have also tried using just the name of...
0
836
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 checks where results are heading 0.0, like round(n,10) for example. My idea was to tell python in some way not to take the type float but decimal in an implicit fassion. It that possible ?
3
1716
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) { var allparams= 'timechk=' + params +'&starttime=' +params1 +'&endtime=' + params2 +'&roomid=' + params3 +'&ckres=' + params4 var ajax = new Ajax.Updater( {success:ck_res}, url, {method: 'get', parameters:allparams, onFailure: reportError});
2
2536
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 user. If it is possible could you please show some sample code?
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.