473,406 Members | 2,220 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,406 software developers and data experts.

Default Button for Enter Key on Web Form

Hi:

I'm a relative newby and I'm writing a C# web application in VS2005.

I have several forms with multiple buttons. In 95% of the cases users
will click a particular button.

I would like to allow them to press the enter key if they are selecting
the "95% of the time" button.

I have tried the "AccessKey" property. If I set the value to "1" then
the button's click event is fired if the user presses ALT-1.

Is there a way to do this for the enter key?

Your help will be GREATLY appreciated!

Thanks,

Fred

Dec 3 '05 #1
4 29229
Those solutions are now obsolete/unnecessary with ASP.NET (original post
mentioned use of VS2005).

There is a new DefaultButton property on the Form and Panel controls.

http://msdn2.microsoft.com/en-us/lib...ultbutton.aspx

http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx
Joshua Flanagan
http://flimflan.com/blog

Zeya wrote:
Check this link it is pretty good:

http://www.kamp-hansen.dk//document.aspx?id=28

http://weblogs.asp.net/pleloup/archi.../09/86794.aspx

Dec 4 '05 #3
Hey Folks:

Thanks for your help - it pointed me in the right direction!

I have found that it is very easy to insert lines in the page_load event
to define the default focus and the default button:

Page_Load(..)
{
Page.Form.DefaultButton = btnEnter.UniqueID;
Page.Form.DefaultFocus = tbxInputField.UniqueId;
}

It works perfectly AND it's only two lines of code!

Thanks for your help!

Fred
Joshua Flanagan wrote:
Those solutions are now obsolete/unnecessary with ASP.NET (original post
mentioned use of VS2005).

There is a new DefaultButton property on the Form and Panel controls.

http://msdn2.microsoft.com/en-us/lib...ultbutton.aspx

http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx
Joshua Flanagan
http://flimflan.com/blog

Zeya wrote:
Check this link it is pretty good:

http://www.kamp-hansen.dk//document.aspx?id=28

http://weblogs.asp.net/pleloup/archi.../09/86794.aspx


Dec 4 '05 #4
Yes, this is an option. But note this option is available with ASP.Net
2.0.

Dec 6 '05 #5

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

Similar topics

1
by: Billy Jacobs | last post by:
Is there a way to make a button on a web form the default button so that when the user hits the enter button the code for that button executes? I have a web page Login.aspx where I have only 1...
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...
4
by: RA | last post by:
Hi I have asp.net web app. When a user clicks the enter key when he is viewing the aspx web form, it jumps to the starting web form. How can I handle the user hitting the enter key and to...
4
by: Anton ml. Vaheie | last post by:
Hi, Can somebody tell me how to convince explorer that my "button" will be pressed when I press Enter - in other words that it will be default button. Just like in windows forms. I use web form...
3
by: Ben de Vette | last post by:
Hi, when I create a form in ASP.NET, how do I define the default Button which is send with the form as being clicked on, when I press the enter. I have three buttons, Update, Delete and...
5
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
2
by: jonefer | last post by:
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...
0
by: MatsL | last post by:
I have a simple test form with a panel and default button defined, textbox, RequiredFieldValidator. If i open the form and press enter the RequiredFieldValidator will prevent the form to be...
1
by: Webmills | last post by:
Hi I have a log out button at the top of my site. It is contained within a web control within the master page. Because it is the first button on the page, then by default it is the one that...
0
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2)...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
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...
0
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,...

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.