472,127 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 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 29146
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Billy Jacobs | last post: by
2 posts views Thread by Bratislav Jevtic | last post: by
4 posts views Thread by RA | last post: by
4 posts views Thread by Anton ml. Vaheie | last post: by
3 posts views Thread by Ben de Vette | last post: by
2 posts views Thread by jonefer | last post: by
reply views Thread by MatsL | last post: by
1 post views Thread by Webmills | last post: by
reply views Thread by leo001 | last post: by

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.